Class 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 java.lang.Object
    implements HttpMessage<B>
    A wrapper around an HttpMessage.
    Since:
    1.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()
      A MutableConvertibleValues of the attributes for this HTTP message.
      java.util.Optional<B> getBody()  
      <T> java.util.Optional<T> getBody​(io.micronaut.core.type.Argument<T> type)
      Return the body as the given type.
      <T> java.util.Optional<T> getBody​(java.lang.Class<T> type)
      Return the body as the given type.
      HttpMessage<B> getDelegate()  
      HttpHeaders getHeaders()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.micronaut.core.attr.AttributeHolder

        getAttribute, getAttribute
      • Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder

        removeAttribute
    • Constructor Detail

      • HttpMessageWrapper

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

      • getDelegate

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

        public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.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 java.util.Optional<B> getBody()
        Specified by:
        getBody in interface HttpMessage<B>
        Returns:
        The request body
      • getBody

        public <T> java.util.Optional<T> getBody​(java.lang.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> java.util.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