Do you ever use Controller functions in your router (in your real apps)?

By default, when generating a Phoenix app, the router files imports the functions from Phoenix.Controller.

Because it generates the following in the MyAppWeb file:

def router do
  quote do
    use Phoenix.Router
    import Plug.Conn
    import Phoenix.Controller
  end
end

However, do you ever really use Controller functions for your app in the router file? And I mean not the small demo app; a real useful production app.

Most of my routes are like the following: get "/", PageController, :index
No use of Controller functions, just paths connected to controller module names and action names.

If you do, for what cases?

Thank you for any input!

A few of the plugs in your pipelines are of Phoenix.Controller, e.g. accepts/2.

1 Like