I’m trying to better understand the relationship between a Phoenix router and a Plug.
I’ve generated the base Phoenix app, created a Plug, Phoenixsimple.HelloPlug.
When I add this line:
forward “/hello”, Phoenixsimple.HelloPlug
to the bottom of the router, localhost:4000/hello runs through the plug which does the following and displays “Hello world” on the web page:
def call(conn, _opts) do
|> send_resp(200, “Hello world”)
But, when instead I eliminate the forward and add a pipleline near the top of the router code:
pipeline :myhello do
Then do the following, after scope “/”:
scope “/hello”, PhoenixsimpleWeb do
When I hit localhost:4000/hello I get “No route found for GET /hello”
Is there no way to use pipe_through? Must I use forward? Why?
Thanks in advance for bettering our understanding of routes and plugs.