Interface Request

All Known Implementing Classes:
MockRequest

public interface Request
This interface provides access to all properties of an HTTP request that are relevant for the REST API.

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 Details

    • getMethod

      String getMethod()
      Getter method for the HTTP method.
      Returns:
      the HTTP method
    • getHeader

      String getHeader(String name)
      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 PathArgument objects.

      Both SimpleHandler and ComplexHandler can 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

      default <T> T parseQuerystring(Class<T> clazz) throws QuerystringParsingException
      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 the QuerystringParserRegistry. Parsers for yet unknown record types will be auto-generated, and parsers for the individual fields will be taken from the FromStringParserRegistry.
      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

      default <T> T parseQuerystring(TypeToken<T> typeToken) throws QuerystringParsingException
      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 the QuerystringParserRegistry. Parsers for yet unknown record types will be auto-generated, and parsers for the individual fields will be taken from the FromStringParserRegistry.
      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

      Object parseQuerystring(Type type) throws QuerystringParsingException
      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 the QuerystringParserRegistry. Parsers for yet unknown record types will be auto-generated, and parsers for the individual fields will be taken from the FromStringParserRegistry.
      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

      default <T> T parseBody(Class<T> clazz)
      Parses the request body using the JSON parsing mechanism defined by JsonEngine and the JSON-able types defined in the engine's JsonRegistries. 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

      default <T> T parseBody(TypeToken<T> typeToken)
      Parses the request body using the JSON parsing mechanism defined by JsonEngine and the JSON-able types defined in the engine's JsonRegistries. 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

      Object parseBody(Type type)
      Parses the request body using the JSON parsing mechanism defined by JsonEngine and the JSON-able types defined in the engine's JsonRegistries. Refer to these classes for details.
      Parameters:
      type - the type to parse as
      Returns:
      the parsed object