0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-16 05:00:24 +00:00

AcceptCallback may now return created/see_other tuples for POST

They replace and deprecate the {true,URI} return value.
This commit is contained in:
Martin Björklund 2020-09-11 12:35:36 +02:00 committed by Loïc Hoguin
parent 63a6b86fba
commit 8795233c57
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
4 changed files with 73 additions and 4 deletions

View file

@ -1104,6 +1104,14 @@ process_content_type(Req, State=#state{method=Method, exists=Exists}, Fun) ->
next(Req2, State2, fun maybe_created/2);
{false, Req2, State2} ->
respond(Req2, State2, 400);
{{created, ResURL}, Req2, State2} when Method =:= <<"POST">> ->
Req3 = cowboy_req:set_resp_header(
<<"location">>, ResURL, Req2),
respond(Req3, State2, 201);
{{see_other, ResURL}, Req2, State2} when Method =:= <<"POST">> ->
Req3 = cowboy_req:set_resp_header(
<<"location">>, ResURL, Req2),
respond(Req3, State2, 303);
{{true, ResURL}, Req2, State2} when Method =:= <<"POST">> ->
Req3 = cowboy_req:set_resp_header(
<<"location">>, ResURL, Req2),