Zarathustra2
Proposal to add generic/matched route to Plug.Conn
Say we have the following router definition
get "/user/:id", UserController, :show
and we have the api request /user/some-id. We can get already the current path from the Plug connection but we cannot get the matched routed from my knowledge.
Getting the matched routed would be nice so that if we persist all requests for analytical purpose we could also save the matched route with the actual route, something like:
route | matched_route | duration_ms | created_at | status | method
That would allow for some nice analytics.
If that is already possible, I would appreciate if someone can point me in that correct direction otherwise I would happily take a look at implementing it.
Most Liked
LostKobrakai
Instead of doing the lookup twice you could also use Plug.Conn.register_before_send and pull out the information you need from the conn, which should then be available.
Zarathustra2
I see, Phoenix.Router.route_info(conn.private[:phoenix_router], conn.method, conn.request_path, "") should do the trick, thanks.








