Closed marcandre closed 2 years ago
A module plug may be initialized at compile-time, so the options are all compile time. Phoenix can address this though by reimplementing the plug
macro and checking to Phoenix.plug_init_mode()
to know the init mode. Then use Plug.Builder.compile to build the function. We do it in other places in Phoenix, so a PR is welcome.
We can't do it in Plug because we don't have the value of init_mode at compile time. In Phoenix it is a global, so it works.
Thank you, this clarifies things. Yes, I saw the code used for controllers, I might have a go at that one day.
@josevalim It looks intentional that the
plug
macro does notexpand_alias
for plugs that are modules... but this means that code like the following will introduce compile-time dependencies (onHexpmWeb.PlugParser
):I'm missing the context here, so I don't understand why there is the
and not module_plug?(plug)
. Is there a way to avoid introducing that compile-time dependency?