Class HttpMessageWrapper<B>

java.lang.Object
io.micronaut.http.HttpMessageWrapper<B>
Type Parameters:
B - The message body
All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder, io.micronaut.core.attr.MutableAttributeHolder, HttpMessage<B>
Direct Known Subclasses:
HttpRequestWrapper, HttpResponseWrapper

public class HttpMessageWrapper<B> extends Object implements HttpMessage<B>
A wrapper around an HttpMessage.
Since:
1.0
  • Constructor Details

    • HttpMessageWrapper

      public HttpMessageWrapper(HttpMessage<B> delegate)
      Parameters:
      delegate - The Http message
  • Method Details

    • getDelegate

      public HttpMessage<B> getDelegate()
      Returns:
      The Http message
    • getHeaders

      public HttpHeaders getHeaders()
      Specified by:
      getHeaders in interface HttpMessage<B>
      Returns:
      The HttpHeaders object
    • getAttributes

      public io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()
      Description copied from interface: HttpMessage

      A MutableConvertibleValues of the attributes for this HTTP message.

      Attributes are designed for internal data sharing and hence are isolated from headers and parameters which are client supplied

      Specified by:
      getAttributes in interface io.micronaut.core.attr.AttributeHolder
      Specified by:
      getAttributes in interface HttpMessage<B>
      Specified by:
      getAttributes in interface io.micronaut.core.attr.MutableAttributeHolder
      Returns:
      The attributes of the message
    • getBody

      public Optional<B> getBody()
      Specified by:
      getBody in interface HttpMessage<B>
      Returns:
      The request body
    • getBody

      public <T> Optional<T> getBody(Class<T> type)
      Description copied from interface: HttpMessage
      Return the body as the given type.
      Specified by:
      getBody in interface HttpMessage<B>
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type of the body
      Returns:
      An Optional of the type or Optional.empty() if the body cannot be returned as the given type
    • getBody

      public <T> Optional<T> getBody(io.micronaut.core.type.Argument<T> type)
      Description copied from interface: HttpMessage
      Return the body as the given type.
      Specified by:
      getBody in interface HttpMessage<B>
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type of the body
      Returns:
      An Optional of the type or Optional.empty() if the body cannot be returned as the given type
    • getBody

      public <T> Optional<T> getBody(io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)
      Description copied from interface: HttpMessage
      Return the body, will use the provided conversion context if needed.
      Specified by:
      getBody in interface HttpMessage<B>
      Type Parameters:
      T - The generic type
      Parameters:
      conversionContext - The body conversion context
      Returns:
      An Optional of the type or Optional.empty() if the body cannot be returned as the given type