Spring REST post process all HTTP requests

Viewed 1955

What I'm Trying to accomplish

I want to be able to process the results of a HTTP request to a Spring RestController after a particular endpoints method has returned it's value. E.g. I have:

GET /customer/{id}

This normally just returns a custom resource. It's endpoint I define in my RestController just returns a customer object.

I want to be able to modify the HttpEntity response that is crafted from this return result. In particular, I want to do all HATEOAS work in this post-processor and wrap it in my parent object.

What would be the best way to accomplish this? I would include what I've tried, but I can't think of any way this could be done cleanly.

In frameworks that implement JAX-RS, all you would need to do is implement the ContainerResponseFilter interface and you could add it to your REST server. This was simple to do with Jersey OR CXF.

Is there a notion of ContainerResponseFilter in Spring REST?

2 Answers
Related