Package io.github.grumpystuff.grumpyrest
Class RequestCycle
java.lang.Object
io.github.grumpystuff.grumpyrest.RequestCycle
Holds the run-time state of processing a single request. Application code will normally not have to deal with a
request cycle directly, but rather implement a
SimpleHandler that takes a Request and returns either
a Response, or a value that gets converted to such a response. Only if this scheme is not flexible enough
will the application implement a ComplexHandler and deal with the request cycle directly.-
Constructor Summary
ConstructorsConstructorDescriptionRequestCycle(RestApi api, jakarta.servlet.http.HttpServletRequest servletRequest, jakarta.servlet.http.HttpServletResponse servletResponse, RequestPathSourcingStrategy requestPathSourcingStrategy) NOT PUBLIC API -
Method Summary
Modifier and TypeMethodDescriptiongetApi()Getter method for theRestApithat handles the requestThe high-levelRequestobject that makes all relevant properties of the HTTP request available.Getter method for the route that matched this request.Getter method for the path arguments that are bound to variables in the path of the matched route.Getter method for the requested path, split into segments at slashesReturns an object that is used byResponseimplementations to transmit the response to the client.jakarta.servlet.http.HttpServletRequestGetter method for the underlying servlet request
-
Constructor Details
-
RequestCycle
public RequestCycle(RestApi api, jakarta.servlet.http.HttpServletRequest servletRequest, jakarta.servlet.http.HttpServletResponse servletResponse, RequestPathSourcingStrategy requestPathSourcingStrategy) NOT PUBLIC API- Parameters:
api- ...servletRequest- ...servletResponse- ...requestPathSourcingStrategy- ...
-
-
Method Details
-
getApi
Getter method for theRestApithat handles the request- Returns:
- the REST API implementation
-
getServletRequest
public jakarta.servlet.http.HttpServletRequest getServletRequest()Getter method for the underlying servlet request- Returns:
- the servlet request
-
getPathSegments
Getter method for the requested path, split into segments at slashes- Returns:
- the path segments
-
getMatchedRoute
Getter method for the route that matched this request. This method must not be called before route matching is completed, otherwise it throws an exception.- Returns:
- the route
-
getPathArguments
Getter method for the path arguments that are bound to variables in the path of the matched route. This method must not be called before route matching is completed, otherwise it throws an exception.The returned list contains elements only for variables in the route's path, not for fixed path segments.
- Returns:
- the path arguments
-
getHighlevelRequest
The high-levelRequestobject that makes all relevant properties of the HTTP request available. This is the object that gets passed to aSimpleHandleras the only parameter.- Returns:
- the request
-
getResponseTransmitter
Returns an object that is used byResponseimplementations to transmit the response to the client. It is an abstraction of theHttpServletResponseand contains methods to send headers as well as the response body.The returned object is called a response transmitter, even though it abstracts the servlet response, because the latter suffers from bad naming: That object isn't really the response itself as much as a mechanism to send a response to the client.
- Returns:
- the response transmitter
-