Created
October 3, 2015 14:03
-
-
Save BillBarnhill/540c7d742b33c3233c7b to your computer and use it in GitHub Desktop.
Snippet showing how to dump request headers into response as JSON, put in controller
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
def mapify({k,v}, m) do | |
Map.put(m, k, v) | |
end | |
def show(conn, %{"id" => id, "as" => "headers"}) do | |
resp_body = conn.req_headers | |
|> List.foldl(Map.new(), &mapify/2) | |
|> Poison.encode! | |
send_resp(conn, 200, resp_body) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment