Package com.soklet.web.response
Interface ResponseHandler
- All Known Implementing Classes:
DefaultResponseHandler
public interface ResponseHandler
Contract for writing an HTTP response.
Implementors should use
handleResponse(HttpServletRequest, HttpServletResponse, Optional, Optional, Optional)
to write an
appropriate HTTP response body, content type, and any relevant headers.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
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.
-
Method Details
-
handleResponse
void handleResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Optional<Route> route, Optional<Object> response, Optional<Exception> exception) throws IOException 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
- 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
-