1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-09 19:52:24 -04:00
httparrot/lib/httparrot/delete_handler.ex
Eduardo Gurgel 704b38006d Add @moduledoc for most handlers
[ci skip]
2014-01-05 12:38:20 -03:00

26 lines
550 B
Elixir

defmodule HTTParrot.DeleteHandler do
@moduledoc """
Returns DELETE data.
"""
alias HTTParrot.GeneralRequestInfo
def init(_transport, _req, _opts) do
{:upgrade, :protocol, :cowboy_rest}
end
def allowed_methods(req, state) do
{["DELETE"], req, state}
end
def delete_resource(req, state) do
{info, req} = GeneralRequestInfo.retrieve(req)
req = :cowboy_req.set_resp_body(response(info), req)
{true, req, state}
end
defp response(info) do
info |> JSEX.encode!
end
def terminate(_, _, _), do: :ok
end