1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-18 04:24:11 -04:00
httparrot/lib/httparrot/headers_handler.ex
2014-07-22 20:33:22 +12:00

16 lines
401 B
Elixir

defmodule HTTParrot.HeadersHandler do
use HTTParrot.Cowboy, methods: ~w(GET HEAD OPTIONS)
def content_types_provided(req, state) do
{[{{"application", "json", []}, :get_json}], req, state}
end
def get_json(req, state) do
{headers, req} = :cowboy_req.headers(req)
{response(headers), req, state}
end
defp response(headers) do
[headers: headers] |> JSEX.encode!
end
end