Zarathustra2
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.
Trending in Proposals: Ideas
We are seeing a lot of warning logs like this:
navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Eiji
You can fetch most if not all of those data. First of all
Phoenixsomehow needs to know what should be applied and there is no magic here. SimplyPhoenixstores those data somewhere. Where exactly … it’sprivate- I mean thefieldinPlug.Connstruct.Following naming
privateyou should not access those data unless some public function do that for you as there is no guarantee that the structure ofprivatedata would be kept in next releases.I would recommend to check the documentation, just for example we have: Phoenix.Controller.action_name/1. If you take a look at source code it fetches a value of
phoenix_actionfromprivatedata:https://github.com/phoenixframework/phoenix/blob/1d8874760c45bbb885f9ebbb2bf49e7fa6a3745d/lib/phoenix/controller.ex#L320-L324
In same module there are functions to fetch
Controller,EndpointandRoutermodules.The
Routeralso allows you to fetch routing information using Phoenix.Router.routes/1Take a deep look at
Phoenixdocumentation and find things you think would be useful for your use case.Zarathustra2
I see,
Phoenix.Router.route_info(conn.private[:phoenix_router], conn.method, conn.request_path, "")should do the trick, thanks.LostKobrakai
Instead of doing the lookup twice you could also use
Plug.Conn.register_before_sendand pull out the information you need from the conn, which should then be available.