I wanted to write a plug for user authetication in my app. Was going through phoenix plug documentation and was a bit confused on which kind of plug to use, function or module.
Generally speaking also, of the two plugs which plug is preferred when?
There are two main uses I can think of when you would want a function plug:
put_layout and scrub_params)Most of the time, my plugs start as functions while I am developing them, then I move them out to their own modules.
The module plug has the benefit of being able to perform some login in the init/1 function that will later be passed to the call/2 function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With