Skip to content

Conversation

@jrrickard
Copy link
Contributor

Issue: DATAREST-34

As mentioned in DATAREST-34 and it's comments, this enhancement enables control of response body negotiation for PUT and POST requests through
the presence of the HTTP Accept header. RepositoryRestConfig.setReturnBodyOnCreate(…) and RepositoryRestConfig.setReturnBodyOnUpdate(…) were converted to Boolean and default to Boolean.FALSE. When set to null, the response body negotiation is controlled by the presence of the Accept header.

For example:
curl -H "Content-Type: application/json" -d '{"id" : "cafebabe","vCenterId" : "cafebabe2","vCenterName" : "nuclab"}' http://localhost:8080/spring-data-rest-test-app-1.0-SNAPSHOT/clients

Returns:

{
"id" : "cafebabe",
"vCenterId" : "cafebabe2",
"vCenterName" : "nuclab",
"_links" : {
"self" : {
"href" : "http://localhost:8080/spring-data-rest-test-app-1.0-SNAPSHOT/clients/cafebabe"
}
}
}

While the following command returns no body:

curl -H "Content-Type: application/json" -H "Accept:" -d '{"id" : "cafebabe2","vCenterId" : "decafbad","vCenterName" : "the decaf lab"}' http://localhost:8080/spring-data-rest-test-app-1.0-SNAPSHOT/clients

I also corrected some of the Javadoc annotations in the RepositoryEntityController class.

I have signed and agree to the terms of the Spring Individual Contributor License Agreement.

@odrotbohm
Copy link
Member

Thanks, Jeremy! Looks good to me, I'll take it from there :).

@odrotbohm odrotbohm self-assigned this Mar 12, 2015
odrotbohm pushed a commit that referenced this pull request Mar 20, 2015
…ult.

By default, whether to return response bodies for PUT and POST is determined by the presence of an Accept header, unless explicitly activated or deactivated in RepositoryRestConfiguration.

Original pull request: #167.
odrotbohm added a commit that referenced this pull request Mar 20, 2015
Moved decision logic on whether to return response bodies int RepositoryRestConfig to ease testability of the controller. Added more unit tests and simplified the controller integration tests accordingly. Had to deactivate some Cassandra related tests as they don't seem to handle nulling of properties correctly.

Changed configuration to rely on the presence of the Accept header by default. Deprecated parameterless isReturnBodyFor…(…) methods in favor of the ones taking the Accept header to avoid the null checks on the calling side.

Polished JavaDoc for the isReturnBodyOn(Create|Update) methods. Polished formatting in RepositoryEntityController.

Original pull request: #167.
@odrotbohm odrotbohm closed this Mar 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants