philomena/lib/philomena_web/plugs/canary_map_plug.ex

19 lines
357 B
Elixir
Raw Normal View History

2019-11-17 19:18:21 +01:00
defmodule PhilomenaWeb.CanaryMapPlug do
2019-11-17 03:53:41 +01:00
import Plug.Conn
def init(opts), do: opts
def call(conn, opts) do
phx_action = conn.private.phoenix_action
2020-01-11 05:20:19 +01:00
2019-11-17 03:53:41 +01:00
canary_action =
case Keyword.fetch(opts, phx_action) do
{:ok, action} -> action
2020-01-11 05:20:19 +01:00
_ -> phx_action
2019-11-17 03:53:41 +01:00
end
conn
|> assign(:canary_action, canary_action)
end
2020-01-11 05:20:19 +01:00
end