silverdr
Request format no longer in params?
There is a fine answer
on SO by @chrismccord about pleasant pattern-matching request format on controller actions, followed by a few comments saying that it does not work. Well - I checked - it doesn’t. A suggestion of digging into private fields of conn instead unfortunately seems far less elegant. I assume this particular answer’s author knew what he was talking about
In such case the param must have been removed at some point. And yes, I can imagine valid reasons for this removal but would like to know a) what was the actual rationale, and b) if there’s any replacement for this, other than mentioned in the comments to the answer (conn/private/phoenix_format) that could be used to pattern-match on controller actions?
Most Liked
LostKobrakai
mcrumm
You can use Phoenix.Controller.get_format/1 to get the format for the current request.
Also note that the param key is "_format" ![]()
Last Post!
LostKobrakai
That’s for sure a valid concern, but this is a documented feature of the framework – just a rarely used one.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









