aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_rest.erl
diff options
context:
space:
mode:
authorMartin Björklund <[email protected]>2020-09-11 12:35:36 +0200
committerLoïc Hoguin <[email protected]>2020-11-27 16:17:43 +0100
commit8795233c57f1f472781a22ffbf186ce38cc5b049 (patch)
tree140478621afdef80d4957e17e417a2751ef7694c /src/cowboy_rest.erl
parent63a6b86fbae1190ba78dceb196588fdcae50e17a (diff)
downloadcowboy-8795233c57f1f472781a22ffbf186ce38cc5b049.tar.gz
cowboy-8795233c57f1f472781a22ffbf186ce38cc5b049.tar.bz2
cowboy-8795233c57f1f472781a22ffbf186ce38cc5b049.zip
AcceptCallback may now return created/see_other tuples for POST
They replace and deprecate the {true,URI} return value.
Diffstat (limited to 'src/cowboy_rest.erl')
-rw-r--r--src/cowboy_rest.erl8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl
index 468f9ab..7d0fe80 100644
--- a/src/cowboy_rest.erl
+++ b/src/cowboy_rest.erl
@@ -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),