Class UninitializedRequest


public class UninitializedRequest extends ServiceRequest<Object>
UninitializedRequest wraps the exchage and provides access to request attributes (such as getPath()) and allows setting a customRequestInitializer The request content can be only accessed in raw format with getRawContent() and setRawContent() Interceptors at intercePoint REQUEST_BEFORE_EXCHANGE_INIT receive UninitializedRequest as request argument
  • Method Details

    • of

      public static UninitializedRequest of(io.undertow.server.HttpServerExchange exchange)
    • getContent

      public Object getContent()
      throws IllegalStateException the content can only be retrieved in raw format, use getRawContent()
      Overrides:
      getContent in class ServiceRequest<Object>
      Returns:
    • setContent

      public void setContent(Object content)
      throws IllegalStateException the content can only be set in raw format, use setRawContent()
      Overrides:
      setContent in class ServiceRequest<Object>
      Parameters:
      content -
    • getRawContent

      public byte[] getRawContent()
      Returns:
      the request body raw bytes
    • setRawContent

      public void setRawContent(byte[] data) throws IOException
      overwrite the request body raw bytes make sense to invoke it before request initialization
      Parameters:
      data -
      Throws:
      IOException
    • setCustomRequestInitializer

      public void setCustomRequestInitializer(Consumer<io.undertow.server.HttpServerExchange> customRequestInitializer)
      If a customRequestInitializer is set (not null), the ServiceExchangeInitializer will delegate to customRequestInitializer.accept(exchange) the responsability to initialize the request
      Parameters:
      customRequestInitializer -
    • customRequestInitializer

      public Consumer<io.undertow.server.HttpServerExchange> customRequestInitializer()
      Returns:
      the custom Consumer used to initialize the request in place of the Service default one
    • parseContent

      public Object parseContent() throws IOException, BadRequestException
      Description copied from class: ServiceRequest
      Parses the content from the exchange and converts it into an instance of the specified type T. This method retrieves data from the exchange, interprets it according to the expected format, and attempts to convert this data into an object of type T.
      Specified by:
      parseContent in class ServiceRequest<Object>
      Returns:
      an instance of T representing the parsed content
      Throws:
      IOException - if an IO error occurs
      BadRequestException - if the content does not match the expected format for type T