I am building a web application in Spring MVC that has a controller level and a service level. My answers are wrapped in a user wrapper that includes the payload and metadata regarding the result of the call (regardless of whether the payload was successful, includes only partial data, etc.) so that I can return HTTP 200 and allow metadata to describe the result call to the client.
Initially, I wrapped the response in the called service, and the controller simply passed the response. However, this template does not work when I need to call my service from other services, because I need to deploy the data first, do some work on it, and then wrap it again and send it back to the controller. Because of this, I started creating a response in controllers.
The problem is that I want my controllers to be as small as possible, to be clear and readable as a mapping of URLs for services.
Are the controllers the right place to create a REST response wrapper or should I leave it in the services?
cspin source
share