mirror of
https://github.com/edgurgel/httparrot
synced 2025-04-06 00:32:34 -04:00
16 lines
420 B
Elixir
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
|