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
ConstructorsConstructorDescriptionDefaultResponseHandler(PageResponseWriter pageResponseWriter, ApiResponseWriter apiResponseWriter, BinaryResponseWriter binaryResponseWriter, RedirectResponseWriter redirectResponseWriter, ExceptionStatusMapper exceptionStatusMapper) -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Optional<Route> route, Optional<Object> response, Optional<Exception> exception) Determines and writes an appropriate response for the client based onRequestHandleroutput.
-
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:ResponseHandlerDetermines and writes an appropriate response for the client based onRequestHandleroutput.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 asvoidor returnednullexception: The exception that occurred during request processing. Empty if no exception occurred
- Specified by:
handleResponsein interfaceResponseHandler- Parameters:
httpServletRequest- Servlet requesthttpServletResponse- Servlet responseroute- The route that matched this request (if any)response- The result of theresourceMethodinvocation (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
-