1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-09 03:32:25 -04:00
httparrot/lib/httparrot/headers_handler.ex
Eduardo Gurgel a049031f67 Rewrite tests to be less integrated
Now mocking JSEX
2013-12-30 23:37:18 -03:00

24 lines
537 B
Elixir

defmodule HTTParrot.HeadersHandler do
def init(_transport, _req, _opts) do
{:upgrade, :protocol, :cowboy_rest}
end
def allowed_methods(req, state) do
{["GET"], req, state}
end
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
def terminate(_, _, _), do: :ok
end