Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Forward Response Content AND Status #17

Merged
merged 2 commits into from
Sep 8, 2015
Merged

Forward Response Content AND Status #17

merged 2 commits into from
Sep 8, 2015

Conversation

ctcudd
Copy link
Contributor

@ctcudd ctcudd commented Sep 6, 2015

Modify service and dao layers to return a ResponseEntity instead of just an Object.

Returning an object is not sufficient as many REST api calls use HTTP status alone to indicate the success, or failure, of an operation (i.e. 204 No Content).

I've also added RestProxyResponseErrorHandler, a ResponseErrorHandler which is always used and does nothing, but it does highlight some important assumptions:
RestProxy's sole responsibility is to relay requests and responses.
It's up to the client to deal with responses, whether they are successes or errors.

RestProxyServiceImpl has also been modified to allow any content type and to only attach a body when the request has a content length greater than zero.

…ead of just an Object.

Returning an object is not sufficient as many REST api calls use HTTP status alone to indicate the success, or failure, of an operation (i.e. 204 No Content).

I've also added RestProxyResponseErrorHandler, a ResponseErrorHandler which is always used and does nothing, but it does highlight some important assumptions:
RestProxy's sole responsibility is to relay requests and responses.
It's up to the client to deal with responses, whether they are successes or errors.

RestProxyServiceImpl has also been modified to allow any content type and to only attach a body when the request has a content length greater than zero.
final String contentType = request.getHeader(HttpHeaders.CONTENT_TYPE);
if(inputStream != null && MediaType.APPLICATION_JSON_VALUE.equals(contentType)) {
final String contentType = request.getContentType();
int contentLength = request.getContentLength();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks like it should fix the brittleness around content type (e.g. application/json;charset=utf-8)

@paulerickson
Copy link
Contributor

👍

nblair added a commit that referenced this pull request Sep 8, 2015
Forward Response Content AND Status
@nblair nblair merged commit e5bc03b into UW-Madison-DoIT:master Sep 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants