I have a Router module that forwards request to other routers.
In this router I have a pipleline comprised of plug(:match)
and plug(:dispatch)
.
defmodule Example.Router do
use Plug.Router
plug(:match)
plug(:dispatch)
forward("/check", to: Example.Route.Check)
get("/", do: send_resp(conn, 200, "router"))
end
In this second module I have the same pipeline:
defmodule Example.Route.Check do
use Plug.Router
plug(:match)
plug(:dispatch)
get "/", do: send_resp(conn, 200, "ok")
end
The issue I see here is that I always seem to need plug(:match)
and plug(:dispatch)
in all Plug
Routers. So I have the following questions:
- Is this really necessary?
- Do all routers need to have a pipeline in the same file they have the routes?