Hi!
I’m curious about the usage of Mix.env()
in Phoenix router. Bamboo recommends to add a conditional route for :dev
environment to see emails that are kept in memory when using Bamboo.LocalAdapter
.
# In your Router
defmodule MyApp.Router do
use Phoenix.Router # or use Plug.Router if you're not using Phoenix
if Mix.env == :dev do
# If using Phoenix
forward "/sent_emails", Bamboo.SentEmailViewerPlug
# If using Plug.Router, make sure to add the `to`
forward "/sent_emails", to: Bamboo.SentEmailViewerPlug
end
end
Others have asked similar questions here and the conclusion seems to be that it’s not a bad practice because routes are compiled. But since Mix
is a build tool, I’m wondering if this holds true when using releases for example, so it will be a better idea to use Application config values.