Skip to content

Instantly share code, notes, and snippets.

@chinnurtb
Forked from yazdotai/httpheaders_resource.erl
Created August 21, 2013 10:32
Show Gist options
  • Select an option

  • Save chinnurtb/6292876 to your computer and use it in GitHub Desktop.

Select an option

Save chinnurtb/6292876 to your computer and use it in GitHub Desktop.
-module(httpheaders_resource).
-export([init/1, to_html/2]).
-include_lib("webmachine/include/webmachine.hrl").
init([]) -> {ok, undefined}.
to_html(ReqData, Context) ->
Headers = mochiweb_headers:to_list(wrq:req_headers(ReqData)),
StringConvert = [{X,list_to_binary(Y)} || {X,Y} <- Headers],
Output = mochijson2:encode({struct, StringConvert}),
Body = io:format("~s~n", [Output]),
{Body, Request, Context}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment