Class ApiRequestHandler

  • All Implemented Interfaces:
    org.springframework.web.servlet.AsyncHandlerInterceptor, org.springframework.web.servlet.HandlerInterceptor

    public class ApiRequestHandler
    extends org.springframework.web.servlet.handler.HandlerInterceptorAdapter
    Adapter class for the AsyncHandlerInterceptor, for register the RequestScope based on TOTVS API Guideline.
    Author:
    Thiago A. de Souza Weber
    See Also:
    AsyncHandlerInterceptor
    • Constructor Detail

      • ApiRequestHandler

        public ApiRequestHandler()
    • Method Detail

      • preHandle

        public boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 Object object)
                          throws Exception
        Intercept the execution of a handler. Called after HandlerMapping determined an appropriate handler object, but before HandlerAdapter invokes the handler.

        This handler capture and register the request parameters 'fields' in RequestScope based on TOTVS API Guideline.

        Also set an HTTP response header (ApiGuideline.HEADER) with the api version defined by the ApiGuideline on RestController.

        Note: It's only applied to RestController with ApiGuideline annotation and not change the request/response default behavior.

        Specified by:
        preHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Overrides:
        preHandle in class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
        Parameters:
        request - current HTTP request
        response - current HTTP response
        object - chosen handler to execute, for type and/or instance evaluation
        Returns:
        true
        Throws:
        Exception - in case of errors