silverdr

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 :wink: 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

LostKobrakai

There‘s also the option to change the parameters on controller actions:

mcrumm

mcrumm

Phoenix Core Team

You can use Phoenix.Controller.get_format/1 to get the format for the current request.

Also note that the param key is "_format" :slight_smile:

Last Post!

LostKobrakai

LostKobrakai

That’s for sure a valid concern, but this is a documented feature of the framework – just a rarely used one.

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement