Skip to content

Provide better intercepting model for controllers returning @ResponseBody [SPR-10859] #15486

@spring-projects-issues

Description

@spring-projects-issues

Marcel Overdijk opened SPR-10859 and commented

I'm using Spring as rest server where all controller actions return @ResponseBody annotated results. Just like Twitter I'm implementing 'suppress_response_codes' functionality.

Normally I will return json response like:

HTTP Status Body
200 { "first_name": "Marcel", "last_name": "Overdijk" }
400 { "error": "the error message" }

But with a suppress_response_codes=true query param in the request it is:

HTTP Status Body
200 { "status": 200, "data": { "first_name": "Marcel", "last_name": "Overdijk" } }
200 { "status": 400, "data": { "error": "the error message" } }

Implementing a HandlerInterceptor does not seem the best fit for intercepting controller actions returning @ResponseBody responsed as the converter seems to have already send the data in the postHandle.

There should be decent intercepting model for @ResponseBody where it's possible to retrieve the original object being returned by the controller actions.


Affects: 3.2.4

Issue Links:

Referenced from: commits c9d0ebd, 96b18c8, 2655c50

6 votes, 12 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions