I somehow forgot Phoenix.Endpoint.init/1 was only for configuration, but can’t a plug at the start of the endpoint do something similar.
defmodule MyApp.Application do
def start(_, _) do
children = [
{MyApp.AceController, config()}
]
…
end
def config() do
…
end
end
vs.
defmodule MyApp.Application do
def start(_, _) do
children = [
MyApp.Endpoint
]
…
end
def config() do
…
end
end
defmodule MyApp.Endpoint do
plug :prime_with_config
def prime_with_config(conn, _),
do: put_in(conn.private.my_app_config, MyApp.Application.config())
end
In both options the context of execution does get the config. I’m sure the first option would be cleaner, though.
It basically takes a conn, applies all the plugs of the endpoint and any router pipes if any and returns the updated conn. Which should solve the issue of sessions not being available and such.


















