Skip to content

Commit 6d19e96

Browse files
committed
Improve documentation of default response body rendering for POST and PUT requests.
Fixes #2063.
1 parent 7e34f6f commit 6d19e96

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/asciidoc/repository-resources.adoc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ For the resources exposed, we use a set of default status codes:
3535

3636
* `200 OK`: For plain `GET` requests.
3737
* `201 Created`: For `POST` and `PUT` requests that create new resources.
38-
* `204 No Content`: For `PUT`, `PATCH`, and `DELETE` requests when the configuration is set to not return response bodies for resource updates (`RepositoryRestConfiguration.returnBodyOnUpdate`). If the configuration value is set to include responses for `PUT`, `200 OK` is returned for updates, and `201 Created` is returned for resource created through `PUT`.
38+
* `204 No Content`: For `PUT`, `PATCH`, and `DELETE` requests when the configuration is set to not return response bodies for resource updates (`RepositoryRestConfiguration.setReturnBodyOnUpdate(…)`).
39+
If the configuration value is set to include responses for `PUT`, `200 OK` is returned for updates, and `201 Created` is returned for resource created through `PUT`.
3940

40-
If the configuration values (`RepositoryRestConfiguration.returnBodyOnUpdate` and `RepositoryRestConfiguration.returnBodyCreate)` are explicitly set to `null`, the presence of the HTTP Accept header is used to determine the response code.
41+
If the configuration values (`RepositoryRestConfiguration.returnBodyOnUpdate(…)` and `RepositoryRestConfiguration.returnBodyCreate(…)`) are explicitly set to `null` -- which they are by default --, the presence of the HTTP Accept header is used to determine the response code.
42+
Read more on this in the detailed description of <<repository-resources.collection-resource.supported-methods.post, collection>> and <<repository-resources.item-resource.supported-methods.put, item resources>>.
4143

4244
[[repository-resources.resource-discoverability]]
4345
=== Resource Discoverability
@@ -144,6 +146,10 @@ For more information on the default exposure of methods, see <<repository-resour
144146
==== `POST`
145147

146148
The `POST` method creates a new entity from the given request body.
149+
By default, whether the response contains a body is controlled by the `Accept` header sent with the request.
150+
If one is sent, a response body is created.
151+
If not, the response body is empty and a representation of the resource created can be obtained by following link contained in the `Location` response header.
152+
This behavior can be overridden by configuring `RepositoryRestConfiguration.setReturnBodyOnCreate(…)` accordingly.
147153

148154
===== Methods used for invocation
149155

@@ -223,6 +229,10 @@ For more information on the default exposure of methods, see <<repository-resour
223229
==== `PUT`
224230

225231
The `PUT` method replaces the state of the target resource with the supplied request body.
232+
By default, whether the response contains a body is controlled by the `Accept` header sent with the request.
233+
If the request header is present, a response body and a status code of `200 OK` is returned.
234+
If no header is present, the response body is empty and a successful request returns a status of `204 No Content`.
235+
This behavior can be overridden by configuring `RepositoryRestConfiguration.setReturnBodyOnUpdate(…)` accordingly.
226236

227237
===== Methods used for invocation
228238

0 commit comments

Comments
 (0)