Class DefaultResponseHandler

java.lang.Object
com.soklet.web.response.DefaultResponseHandler
All Implemented Interfaces:
ResponseHandler

@Singleton public class DefaultResponseHandler extends Object implements ResponseHandler
Since:
1.0.0
Author:
Mark Allen
  • Constructor Details

  • Method Details

    • handleResponse

      public void handleResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Optional<Route> route, Optional<Object> response, Optional<Exception> exception) throws IOException
      Description copied from interface: ResponseHandler
      Determines and writes an appropriate response for the client based on RequestHandler output.

      Optionals are as follows:

      • route: The route matching the request. Empty if no matching method was found for the request URL (normally you'll want to return a 404 in this case)
      • response: The return value of the method invoked to handle this request. Empty if the method is declared as void or returned null
      • exception: The exception that occurred during request processing. Empty if no exception occurred
      Specified by:
      handleResponse in interface ResponseHandler
      Parameters:
      httpServletRequest - Servlet request
      httpServletResponse - Servlet response
      route - The route that matched this request (if any)
      response - The result of the resourceMethod invocation (if any)
      exception - The exception that occurred when attempting to handle the request (if any)
      Throws:
      IOException - If an error occurs while writing the response