Interface Request
A SimpleHandler only gets this interface and returns a response value from that. For most bases, this is
sufficient. Complex cases implement ComplexHandler instead to get access to the whole RequestCycle.
However, even then, the handler accesses request properties using this interface, by calling
RequestCycle.getHighlevelRequest().
-
Method Summary
Modifier and TypeMethodDescriptionGetter method for HTTP request headers.Getter method for the HTTP method.Getter method for the path arguments bound to path parameters in the matched route.<T> TParses the request body using the JSON parsing mechanism defined byJsonEngineand the JSON-able types defined in the engine'sJsonRegistries.<T> TParses the request body using the JSON parsing mechanism defined byJsonEngineand the JSON-able types defined in the engine'sJsonRegistries.Parses the request body using the JSON parsing mechanism defined byJsonEngineand the JSON-able types defined in the engine'sJsonRegistries.<T> TparseQuerystring(TypeToken<T> typeToken) Parses the whole querystring into an object.<T> TparseQuerystring(Class<T> clazz) Parses the whole querystring into an object.parseQuerystring(Type type) Parses the whole querystring into an object.
-
Method Details
-
getMethod
String getMethod()Getter method for the HTTP method.- Returns:
- the HTTP method
-
getHeader
Getter method for HTTP request headers. Returns null if a header is not present.Neither this method nor its return value provides any high-level parsing. There is simply not enough consistency between the various HTTP headers to make this useful.
- Parameters:
name- the name of the header to return- Returns:
- the header value, as a string, or null if not present
-
getPathArguments
List<PathArgument> getPathArguments()Getter method for the path arguments bound to path parameters in the matched route.The returned list contains one element per path parameter. That is, literal path segments do not appear in the returned list.
The path arguments keep the values of the corresponding segments of the request path in their textual form. No parsing or mapping to application types has been performed at this point. Instead, parsing as an application type is done by calling methods on the returned
PathArgumentobjects.Both
SimpleHandlerandComplexHandlercan always call this method. During request processing, and before the handler gets called, however, there is a point where this method is not allowed to be called. This is before a route has been matched and the match result applied to the request.- Returns:
- the path arguments
-
parseQuerystring
Parses the whole querystring into an object. This object is usually a Java record with a one-to-one mapping of querystring parameters to record fields, but custom parsing can be defined through theQuerystringParserRegistry. Parsers for yet unknown record types will be auto-generated, and parsers for the individual fields will be taken from theFromStringParserRegistry.- Type Parameters:
T- the static type of the class to parse as- Parameters:
clazz- the class to parse as, usually a record class- Returns:
- the parsed object
- Throws:
QuerystringParsingException- on parsing errors, such as wrongly formatted fields, unknown fields, missing fields or duplicate fields
-
parseQuerystring
Parses the whole querystring into an object. This object is usually a Java record with a one-to-one mapping of querystring parameters to record fields, but custom parsing can be defined through theQuerystringParserRegistry. Parsers for yet unknown record types will be auto-generated, and parsers for the individual fields will be taken from theFromStringParserRegistry.- Type Parameters:
T- the static type to parse as- Parameters:
typeToken- a type token for the type to parse as- Returns:
- the parsed object
- Throws:
QuerystringParsingException- on parsing errors, such as wrongly formatted fields, unknown fields, missing fields or duplicate fields
-
parseQuerystring
Parses the whole querystring into an object. This object is usually a Java record with a one-to-one mapping of querystring parameters to record fields, but custom parsing can be defined through theQuerystringParserRegistry. Parsers for yet unknown record types will be auto-generated, and parsers for the individual fields will be taken from theFromStringParserRegistry.- Parameters:
type- the type to parse as- Returns:
- the parsed object
- Throws:
QuerystringParsingException- on parsing errors, such as wrongly formatted fields, unknown fields, missing fields or duplicate fields
-
parseBody
Parses the request body using the JSON parsing mechanism defined byJsonEngineand the JSON-able types defined in the engine'sJsonRegistries. Refer to these classes for details.- Type Parameters:
T- the static type of the class to parse as- Parameters:
clazz- the class to parse as- Returns:
- the parsed object
-
parseBody
Parses the request body using the JSON parsing mechanism defined byJsonEngineand the JSON-able types defined in the engine'sJsonRegistries. Refer to these classes for details.- Type Parameters:
T- the static type to parse as- Parameters:
typeToken- a type token for the type to parse as- Returns:
- the parsed object
-
parseBody
Parses the request body using the JSON parsing mechanism defined byJsonEngineand the JSON-able types defined in the engine'sJsonRegistries. Refer to these classes for details.- Parameters:
type- the type to parse as- Returns:
- the parsed object
-