philomena/lib/philomena_web/plugs/not_found_plug.ex
2019-12-14 22:25:11 -05:00

15 lines
384 B
Elixir

defmodule PhilomenaWeb.NotFoundPlug do
alias Phoenix.Controller
alias Plug.Conn
def init([]), do: []
def call(conn), do: call(conn, nil)
def call(conn, _opts) do
conn
|> Controller.fetch_flash()
|> Controller.put_flash(:error, "Couldn't find what you were looking for!")
|> Controller.redirect(external: conn.assigns.referrer)
|> Conn.halt()
end
end