Package io.micronaut.http
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 java.lang.Object implements HttpMessage<B>
A wrapper around anHttpMessage.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description HttpMessageWrapper(HttpMessage<B> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>getAttributes()AMutableConvertibleValuesof 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()HttpHeadersgetHeaders()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.http.HttpMessage
getCharacterEncoding, getContentLength, getContentType, getLocale, setAttribute
-
-
-
-
Constructor Detail
-
HttpMessageWrapper
public HttpMessageWrapper(HttpMessage<B> delegate)
- Parameters:
delegate- The Http message
-
-
Method Detail
-
getDelegate
public HttpMessage<B> getDelegate()
- Returns:
- The Http message
-
getHeaders
public HttpHeaders getHeaders()
- Specified by:
getHeadersin interfaceHttpMessage<B>- Returns:
- The
HttpHeadersobject
-
getAttributes
public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()
Description copied from interface:HttpMessageA
MutableConvertibleValuesof 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:
getAttributesin interfaceio.micronaut.core.attr.AttributeHolder- Specified by:
getAttributesin interfaceHttpMessage<B>- Specified by:
getAttributesin interfaceio.micronaut.core.attr.MutableAttributeHolder- Returns:
- The attributes of the message
-
getBody
public java.util.Optional<B> getBody()
- Specified by:
getBodyin interfaceHttpMessage<B>- Returns:
- The request body
-
getBody
public <T> java.util.Optional<T> getBody(java.lang.Class<T> type)
Description copied from interface:HttpMessageReturn the body as the given type.- Specified by:
getBodyin interfaceHttpMessage<B>- Type Parameters:
T- The generic type- Parameters:
type- The type of the body- Returns:
- An
Optionalof the type orOptional.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:HttpMessageReturn the body as the given type.- Specified by:
getBodyin interfaceHttpMessage<B>- Type Parameters:
T- The generic type- Parameters:
type- The type of the body- Returns:
- An
Optionalof the type orOptional.empty()if the body cannot be returned as the given type
-
-