1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-17 20:14:10 -04:00
httparrot/lib/httparrot/headers_handler.ex
2015-02-09 21:13:20 +13:00

16 lines
400 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] |> JSX.encode!
end
end