What format did client request

I feel like I’m missing something obvious here. I want to know what format the client requested, and surely ought to be able to get that info without parsing the accept header(s) myself. To be clear conn[:private][:phoenix_format] has exactly what I want, but I don’t like digging into something called “private”.

For more background, that will contain either “json” or “protobuf”. I have done the config :mime... & recompile deps stuff necessary to recognize all 3 options for protobuf. So plug accepts: ["json", "protobuf"] is working correctly, and I just want the controller code to be clean(ish).

https://hexdocs.pm/phoenix/Phoenix.Controller.html#get_format/1 ^.^

2 Likes

and… there it is! thanks

1 Like

It seems there was a possibility to elegantly pattern-match on controller actions:

but it’s no longer there. FWIW I opened another thread looking for a replacement.