After
iex -S mix phx.server
I want to do some quick tests in the iex terminal, but some functions require the struct %Plug.Conn{} as an argument, for example I wanted to get the result of expression:
MyAppWeb.Router.Helpers.confirmation_url(%Plug.Conn{}, :edit, "12345")
But I've got error:
Phoenix endpoint not found in %{}
Is there a simple way of getting conn struct in the console?
Router helper functions accept either a conn or an endpoint module as the first argument. You can pass the endpoint module of your app when you want to generate a URL without a conn:
Edit: If you want to create a dummy conn that works with Router helpers, it seems like it's enough to put a
%{phoenix_endpoint: MyAppWeb.Endpoint}
value inconn.private
as of Phoenix 1.3: