-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
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:
- Add JSONP support to MappingJackson2MessageConverter [SPR-9899] #14532 Add JSONP support to MappingJackson2MessageConverter ("is depended on by")
- Consider adding a post-processing hook for the return value of @RequestMapping methods [SPR-10367] #15000 Consider adding a post-processing hook for the return value of
@RequestMapping
methods ("is duplicated by") - MockMvc ignores HTTP status code overridden by filter [SPR-11760] #16382 MockMvc ignores HTTP status code overridden by filter
- Integrate Jackson @JsonView [SPR-7156] #11815 Integrate Jackson
@JsonView
- Response is committed before Interceptor postHandle invoked [SPR-9226] #13864 Response is committed before Interceptor postHandle invoked ("supersedes")
- Make HandlerInterceptor play nice with @ResponseBody [SPR-7897] #12553 Make HandlerInterceptor play nice with
@ResponseBody
("supersedes")
Referenced from: commits c9d0ebd, 96b18c8, 2655c50
6 votes, 12 watchers