We would like to perform validation on all the API endpoints inside our spring boot application. The validation logic relies on passing few request properties to another service S and getting the validation result from this remote service S. This validation logic is common to all the API endpoints.
We would like to implement the validator just once either in the form of an Spring MVC interceptor or a Servlet filter. However, inside either of the interceptor/filter we need to make a network call to service S.
What is the best way to achieve this ? Without a common interceptor/filter validator, this validation would be part of each API endpoint of each Spring Rest Controller and we could then return DeferredResult. However pushing this logic to Interceptor would make it difficult to use DeferredResult from the original Rest controller handler.