I'm building a web app in Spring MVC that has a controller layer and a service layer. My responses are wrapped in a custom wrapper that includes the payload and metadata as to the outcome of the invocation (whether or not the payload was successful, includes only partial data, etc.) so that I can return an HTTP 200 and let the metadata describe the outcome of the invocation to the client.
Originally I was wrapping the response in the service that was invoked and having the controller just pass along the response. However, this pattern doesn't work well when I need to call my service from other services, because I have to first unwrap the data, do some work on it, then wrap it again and send it back to the controller. Because of this, I began building the response in the controllers instead.
The problem is that I want to keep my controllers as small as possible so that they are clear and readable as a mapping of urls to services.
Are the controllers the proper place to build the REST response wrapper, or should I leave it to the services?