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()
AMutableConvertibleValues
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.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:
getHeaders
in interfaceHttpMessage<B>
- Returns:
- The
HttpHeaders
object
-
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 interfaceio.micronaut.core.attr.AttributeHolder
- Specified by:
getAttributes
in interfaceHttpMessage<B>
- Specified by:
getAttributes
in interfaceio.micronaut.core.attr.MutableAttributeHolder
- Returns:
- The attributes of the message
-
getBody
public java.util.Optional<B> getBody()
- Specified by:
getBody
in interfaceHttpMessage<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 interfaceHttpMessage<B>
- Type Parameters:
T
- The generic type- Parameters:
type
- The type of the body- Returns:
- An
Optional
of 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:HttpMessage
Return the body as the given type.- Specified by:
getBody
in interfaceHttpMessage<B>
- Type Parameters:
T
- The generic type- Parameters:
type
- The type of the body- Returns:
- An
Optional
of the type orOptional.empty()
if the body cannot be returned as the given type
-
-