From 8795233c57f1f472781a22ffbf186ce38cc5b049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bj=C3=B6rklund?= Date: Fri, 11 Sep 2020 12:35:36 +0200 Subject: AcceptCallback may now return created/see_other tuples for POST They replace and deprecate the {true,URI} return value. --- src/cowboy_rest.erl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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), -- cgit v1.2.3