1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-05 08:12:31 -04:00

Reply 'application/json' as content-type on '/post'

This commit is contained in:
Eduardo Gurgel 2014-01-02 01:29:05 -03:00
parent 28d06eac1b
commit 15ad5d5e65

View file

@ -8,11 +8,16 @@ defmodule HTTParrot.PostHandler do
def allowed_methods(req, state) do
{["POST"], req, state}
end
def content_types_accepted(req, state) do
{[{{"application", "json", :*}, :post_json},
{{"application", "x-www-form-urlencoded", :*}, :post_form}], req, state}
end
def content_types_provided(req, state) do
{[{{"application", "json", []}, :undefined}], req, state}
end
def post_form(req, _state) do
{:ok, body, req} = :cowboy_req.body_qs(req)
post(req, [form: body, data: "", json: nil])