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. --- doc/src/manual/cowboy_rest.asciidoc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'doc/src/manual/cowboy_rest.asciidoc') diff --git a/doc/src/manual/cowboy_rest.asciidoc b/doc/src/manual/cowboy_rest.asciidoc index a445948..0bb6d47 100644 --- a/doc/src/manual/cowboy_rest.asciidoc +++ b/doc/src/manual/cowboy_rest.asciidoc @@ -86,7 +86,10 @@ normal:: ---- AcceptCallback(Req, State) -> {Result, Req, State} -Result :: true | {true, URI :: iodata()} | false} +Result :: true + | {created, URI :: iodata()} + | {see_other, URI :: iodata()} + | false Default - crash ---- @@ -99,11 +102,14 @@ For PUT requests, the body is a representation of the resource that is being created or replaced. For POST requests, the body is typically application-specific -instructions on how to process the request, but it may also -be a representation of the resource. When creating a new -resource with POST at a different location, return `{true, URI}` +instructions on how to process the request, but it may also be a +representation of the resource. When creating a new resource with POST +at a different location, return `{created, URI}` or `{see_other, URI}` with `URI` the new location. +The `see_other` tuple will redirect the client to the new location +automatically. + For PATCH requests, the body is a series of instructions on how to update the resource. Patch files or JSON Patch are examples of such media types. @@ -724,6 +730,9 @@ listed here, like the authorization header. == Changelog +* *2.9*: An `AcceptCallback` can now return `{created, URI}` or + `{see_other, URI}`. The return value `{true, URI}` + is deprecated. * *2.7*: The media type wildcard in `content_types_accepted` is now documented. * *2.6*: The callback `rate_limited` was added. -- cgit v1.2.3