diff --git a/lib/clacks_web/plug/format.ex b/lib/clacks_web/plug/format.ex index ac89044..b58ebe3 100644 --- a/lib/clacks_web/plug/format.ex +++ b/lib/clacks_web/plug/format.ex @@ -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