Browse Source

Add override format query param

master
Shadowfacts 1 year ago
parent
commit
77bca46197
Signed by: shadowfacts GPG Key ID: 94A5AB95422746E5
1 changed files with 14 additions and 1 deletions
  1. +14
    -1
      lib/clacks_web/plug/format.ex

+ 14
- 1
lib/clacks_web/plug/format.ex View File

@ -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…
Cancel
Save