Last active
April 21, 2020 16:36
-
-
Save lukeledet/84a5b5ef1c9f7cbe42ada2a9e10e2686 to your computer and use it in GitHub Desktop.
Debug HTTP headers plug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Plug.DebugHTTPHeaders do | |
@moduledoc """ | |
Plug to debug request and response headers. Add it to TSSWeb.Endpoint before | |
any other plugs to ensure you see all headers. If you add it to the router | |
another plug might handle the response before this one. | |
THIS IS MEANT FOR USE IN DEVELOPMENT ONLY. | |
If you see this plug used in a pull request, reject it. | |
""" | |
def init(opts) do | |
opts | |
end | |
def call(conn, _) do | |
IO.inspect(conn.req_headers, label: "Request headers") | |
Plug.Conn.register_before_send(conn, fn conn -> | |
IO.inspect(conn.resp_headers, label: "Response headers") | |
conn | |
end) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment