Skip to content

Instantly share code, notes, and snippets.

@motephyr
Created September 12, 2017 05:04
Show Gist options
  • Save motephyr/f5c5a81ef286fb7e18946e073a8b3686 to your computer and use it in GitHub Desktop.
Save motephyr/f5c5a81ef286fb7e18946e073a8b3686 to your computer and use it in GitHub Desktop.
defmodule BidhouseWeb.Router do
use BidhouseWeb, :router
use Coherence.Router # Add this
use ExAdmin.Router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Coherence.Authentication.Session # Add this
plug NavigationHistory.Tracker, excluded_paths: ["/login", "/sessions", "/auth"]
plug :trim_tag
end
def trim_tag(conn, _opts) do
Plug.Conn.register_before_send(conn, fn(conn) ->
case get_resp_header(conn, "content-type") do
[content_type | _tail] ->
if String.contains?(content_type, "text/html") do
resp(conn, conn.status, conn.resp_body |> to_string |> String.replace( ~r/>\s+/, ">") )
else
conn
end
_ -> conn
end
end)
end
#...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment