Skip to content

Instantly share code, notes, and snippets.

@BillBarnhill
Created October 3, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BillBarnhill/540c7d742b33c3233c7b to your computer and use it in GitHub Desktop.
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
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