Add override format query param
This commit is contained in:
parent
7d071d971c
commit
77bca46197
|
@ -4,7 +4,20 @@ defmodule ClacksWeb.Plug.Format do
|
|||
def init(opts), do: opts
|
||||
|
||||
def call(conn, _opts) do
|
||||
format = Phoenix.Controller.get_format(conn)
|
||||
conn = fetch_query_params(conn)
|
||||
|
||||
format =
|
||||
case conn.query_params do
|
||||
%{"format" => format} when format in ["activity+json", "html"] ->
|
||||
format
|
||||
|
||||
%{"format" => "json"} ->
|
||||
"activity+json"
|
||||
|
||||
_ ->
|
||||
Phoenix.Controller.get_format(conn)
|
||||
end
|
||||
|
||||
assign(conn, :format, format)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue