1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-06 00:32:34 -04:00
httparrot/lib/httparrot/status_code_handler.ex
2019-06-30 14:44:33 +12:00

16 lines
420 B
Elixir

defmodule HTTParrot.StatusCodeHandler do
@moduledoc """
Returns given HTTP Status code.
"""
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
code = :cowboy_req.binding(:code, req)
req = :cowboy_req.reply(code, %{}, "", req)
{:stop, req, state}
end
end