Phoenix - New Route from User Input - Adding Route Programmatically

:waving_hand:

There wouldn’t be any performance issues if done correctly. I have a plug for webhooks that are generated at runtime to which I forward from the phoenix router module.

It works roughly like this

# in the router.ex
scope "/" do
  # ...
  forward "/webhooks", MyAppWeb.Plugs.WebHooks
end

# in plugs/web_hooks.ex
def call(%Plug.Conn{path_info: path_info, params: params} = conn, _opts) do
  if handler = get_webhook_handler(path_info) do
    handler.handle!(params)    
  end
  
  send_resp(conn, :ok, [])
end