Creating a simple phoenix plug


Plug is a execution component in Phoenix processing pipeline. Here we're gonna create one and hook it up to the existing pipeline. First you need the code below.





The most important thing to do here is to define

a) init which execute "call" method.

b) call method -> which has the actual functions / implementation of what you're going to do.
For this example, we're just going to write a simple output to the screen.




if  you look at line 12, we're already tied up our plug and pass in a parameter with the value "en".

If you run your "mix phoenix.server" and make a request, you should be able to see some funny output on the command prompt.











Comments

Popular posts from this blog

ionic2 cordova build android - Unable resolve gradle 2.2.3

A quick tutorial for OWASP ZAP tool for beginners