Package com.soklet.web.response
Class DefaultResponseHandler
java.lang.Object
com.soklet.web.response.DefaultResponseHandler
- All Implemented Interfaces:
ResponseHandler
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Constructor Summary
ConstructorDescriptionDefaultResponseHandler
(PageResponseWriter pageResponseWriter, ApiResponseWriter apiResponseWriter, BinaryResponseWriter binaryResponseWriter, RedirectResponseWriter redirectResponseWriter, ExceptionStatusMapper exceptionStatusMapper) -
Method Summary
Modifier and TypeMethodDescriptionvoid
handleResponse
(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Optional<Route> route, Optional<Object> response, Optional<Exception> exception) Determines and writes an appropriate response for the client based onRequestHandler
output.
-
Constructor Details
-
DefaultResponseHandler
@Inject public DefaultResponseHandler(PageResponseWriter pageResponseWriter, ApiResponseWriter apiResponseWriter, BinaryResponseWriter binaryResponseWriter, RedirectResponseWriter redirectResponseWriter, ExceptionStatusMapper exceptionStatusMapper)
-
-
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 onRequestHandler
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 asvoid
or returnednull
exception
: The exception that occurred during request processing. Empty if no exception occurred
- Specified by:
handleResponse
in interfaceResponseHandler
- Parameters:
httpServletRequest
- Servlet requesthttpServletResponse
- Servlet responseroute
- The route that matched this request (if any)response
- The result of theresourceMethod
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
-