Package io.micronaut.http
Class MutableHttpRequestWrapper<B>
java.lang.Object
io.micronaut.http.HttpMessageWrapper<B>
io.micronaut.http.HttpRequestWrapper<B>
io.micronaut.http.MutableHttpRequestWrapper<B>
- Type Parameters:
B
- Body type
- All Implemented Interfaces:
AttributeHolder
,MutableAttributeHolder
,ConversionServiceAware
,HttpMessage<B>
,HttpRequest<B>
,MutableHttpMessage<B>
,MutableHttpRequest<B>
@Internal
public class MutableHttpRequestWrapper<B>
extends HttpRequestWrapper<B>
implements MutableHttpRequest<B>
Wrapper around an immutable
HttpRequest
that allows mutation.- Since:
- 4.0.0
-
Field Summary
Fields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS
-
Constructor Summary
ModifierConstructorDescriptionprotected
MutableHttpRequestWrapper
(ConversionService conversionService, HttpRequest<B> delegate) -
Method Summary
Modifier and TypeMethodDescription<T> MutableHttpRequest<T>
body
(T body) Sets the body.Sets the specified cookie on the request.getBody()
Return the body as the given type.<T> Optional<T>
getBody
(ArgumentConversionContext<T> conversionContext) Return the body, will use the provided conversion context if needed.getUri()
void
setConversionService
(ConversionService conversionService) Sets the conversion service.Sets the uri on the request.static MutableHttpRequest<?>
wrapIfNecessary
(ConversionService conversionService, HttpRequest<?> request) Methods inherited from class io.micronaut.http.HttpRequestWrapper
accept, getCertificate, getCookies, getDelegate, getHttpVersion, getLocale, getMethod, getMethodName, getPath, getRemoteAddress, getServerAddress, getServerName, getSslSession, getUserPrincipal, getUserPrincipal, isSecure, setAttribute
Methods inherited from class io.micronaut.http.HttpMessageWrapper
getAttributes, getBody
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.http.HttpMessage
getAttributes, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType
Methods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getOrigin, getPath, getRemoteAddress, getServerAddress, getServerName, getSslSession, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
Methods inherited from interface io.micronaut.http.MutableHttpMessage
bodyWriter
Methods inherited from interface io.micronaut.http.MutableHttpRequest
accept, accept, basicAuth, bearerAuth, contentEncoding, contentLength, contentType, contentType, cookies, header, headers, headers, toMutableRequest, uri
-
Constructor Details
-
MutableHttpRequestWrapper
-
-
Method Details
-
wrapIfNecessary
public static MutableHttpRequest<?> wrapIfNecessary(ConversionService conversionService, HttpRequest<?> request) -
getBody
- Specified by:
getBody
in interfaceHttpMessage<B>
- Overrides:
getBody
in classHttpMessageWrapper<B>
- Returns:
- The request body
-
getBody
Description copied from interface:HttpMessage
Return the body as the given type.- Specified by:
getBody
in interfaceHttpMessage<B>
- Overrides:
getBody
in classHttpMessageWrapper<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
Description copied from interface:HttpMessage
Return the body, will use the provided conversion context if needed.- Specified by:
getBody
in interfaceHttpMessage<B>
- Overrides:
getBody
in classHttpMessageWrapper<B>
- Type Parameters:
T
- The generic type- Parameters:
conversionContext
- The body conversion context- Returns:
- An
Optional
of the type orOptional.empty()
if the body cannot be returned as the given type
-
cookie
Description copied from interface:MutableHttpRequest
Sets the specified cookie on the request.- Specified by:
cookie
in interfaceMutableHttpRequest<B>
- Parameters:
cookie
- the Cookie to return to the client- Returns:
- The http request
-
uri
Description copied from interface:MutableHttpRequest
Sets the uri on the request.- Specified by:
uri
in interfaceMutableHttpRequest<B>
- Parameters:
uri
- The uri to call- Returns:
- The http request
-
getUri
- Specified by:
getUri
in interfaceHttpRequest<B>
- Overrides:
getUri
in classHttpRequestWrapper<B>
- Returns:
- The full request URI
-
getParameters
- Specified by:
getParameters
in interfaceHttpRequest<B>
- Specified by:
getParameters
in interfaceMutableHttpRequest<B>
- Overrides:
getParameters
in classHttpRequestWrapper<B>
- Returns:
- The HTTP parameters contained with the URI query string
-
getHeaders
- Specified by:
getHeaders
in interfaceHttpMessage<B>
- Specified by:
getHeaders
in interfaceMutableHttpMessage<B>
- Specified by:
getHeaders
in interfaceMutableHttpRequest<B>
- Overrides:
getHeaders
in classHttpMessageWrapper<B>
- Returns:
- The
HttpHeaders
object
-
body
Description copied from interface:MutableHttpMessage
Sets the body.- Specified by:
body
in interfaceMutableHttpMessage<B>
- Specified by:
body
in interfaceMutableHttpRequest<B>
- Type Parameters:
T
- The new body type- Parameters:
body
- The body- Returns:
- This message
-
setConversionService
Description copied from interface:ConversionServiceAware
Sets the conversion service.- Specified by:
setConversionService
in interfaceConversionServiceAware
- Parameters:
conversionService
- The conversion service
-