public class ServerRequestWrapper extends java.lang.Object implements ServerRequest
ServerRequest interface that can be subclassed
to adapt the request in a
handler filter function.
All methods default to calling through to the wrapped request.| Modifier and Type | Class and Description |
|---|---|
static class |
ServerRequestWrapper.HeadersWrapper
Implementation of the
Headers interface that can be subclassed
to adapt the headers in a
handler filter function. |
ServerRequest.Headers| Constructor and Description |
|---|
ServerRequestWrapper(ServerRequest delegate)
Create a new
ServerRequestWrapper that wraps the given request. |
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<java.lang.Object> |
attribute(java.lang.String name)
Return the request attribute value if present.
|
java.util.Map<java.lang.String,java.lang.Object> |
attributes()
Return a mutable map of request attributes.
|
<T> T |
body(BodyExtractor<T,? super ServerHttpRequest> extractor)
Extract the body with the given
BodyExtractor. |
<T> T |
body(BodyExtractor<T,? super ServerHttpRequest> extractor,
java.util.Map<java.lang.String,java.lang.Object> hints)
Extract the body with the given
BodyExtractor and hints. |
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(java.lang.Class<? extends T> elementClass)
Extract the body to a
Flux. |
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Flux. |
<T> reactor.core.publisher.Mono<T> |
bodyToMono(java.lang.Class<? extends T> elementClass)
Extract the body to a
Mono. |
<T> reactor.core.publisher.Mono<T> |
bodyToMono(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Mono. |
MultiValueMap<java.lang.String,HttpCookie> |
cookies()
Return the cookies of this request.
|
reactor.core.publisher.Mono<MultiValueMap<java.lang.String,java.lang.String>> |
formData()
Return the form data from the body of the request if the Content-Type is
"application/x-www-form-urlencoded" or an empty map otherwise. |
ServerRequest.Headers |
headers()
Return the headers of this request.
|
HttpMethod |
method()
Return the HTTP method.
|
java.lang.String |
methodName()
Return the name of the HTTP method.
|
reactor.core.publisher.Mono<MultiValueMap<java.lang.String,Part>> |
multipartData()
Return the parts of a multipart request if the Content-Type is
"multipart/form-data" or an empty map otherwise. |
java.lang.String |
path()
Return the request path.
|
PathContainer |
pathContainer()
Return the request path as
PathContainer. |
java.lang.String |
pathVariable(java.lang.String name)
Return the path variable with the given name, if present.
|
java.util.Map<java.lang.String,java.lang.String> |
pathVariables()
Return all path variables for this request.
|
reactor.core.publisher.Mono<? extends java.security.Principal> |
principal()
Return the authenticated user for the request, if any.
|
java.util.Optional<java.lang.String> |
queryParam(java.lang.String name)
Return the first query parameter with the given name, if present.
|
MultiValueMap<java.lang.String,java.lang.String> |
queryParams()
Return all query parameters for this request.
|
ServerRequest |
request()
Return the wrapped request.
|
reactor.core.publisher.Mono<WebSession> |
session()
Return the web session for this request.
|
java.net.URI |
uri()
Return the request URI.
|
UriBuilder |
uriBuilder()
Return a
UriBuilderComponents from the URI associated with this
ServerRequest, while also overlaying with values from the headers
"Forwarded" (RFC 7239),
or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if
"Forwarded" is not found. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreatepublic ServerRequestWrapper(ServerRequest delegate)
ServerRequestWrapper that wraps the given request.delegate - the request to wrappublic ServerRequest request()
public HttpMethod method()
ServerRequestmethod in interface ServerRequestnull
if not resolvable (e.g. in case of a non-standard HTTP method)public java.lang.String methodName()
ServerRequestmethodName in interface ServerRequestpublic java.net.URI uri()
ServerRequesturi in interface ServerRequestpublic UriBuilder uriBuilder()
ServerRequestUriBuilderComponents from the URI associated with this
ServerRequest, while also overlaying with values from the headers
"Forwarded" (RFC 7239),
or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if
"Forwarded" is not found.uriBuilder in interface ServerRequestpublic java.lang.String path()
ServerRequestpath in interface ServerRequestpublic PathContainer pathContainer()
ServerRequestPathContainer.pathContainer in interface ServerRequestpublic ServerRequest.Headers headers()
ServerRequestheaders in interface ServerRequestpublic MultiValueMap<java.lang.String,HttpCookie> cookies()
ServerRequestcookies in interface ServerRequestpublic <T> T body(BodyExtractor<T,? super ServerHttpRequest> extractor)
ServerRequestBodyExtractor.body in interface ServerRequestT - the type of the body returnedextractor - the BodyExtractor that reads from the requestServerRequest.body(BodyExtractor, Map)public <T> T body(BodyExtractor<T,? super ServerHttpRequest> extractor, java.util.Map<java.lang.String,java.lang.Object> hints)
ServerRequestBodyExtractor and hints.body in interface ServerRequestT - the type of the body returnedextractor - the BodyExtractor that reads from the requesthints - the map of hints like Jackson2CodecSupport.JSON_VIEW_HINT
to use to customize body extractionpublic <T> reactor.core.publisher.Mono<T> bodyToMono(java.lang.Class<? extends T> elementClass)
ServerRequestMono.bodyToMono in interface ServerRequestT - the element typeelementClass - the class of element in the Monopublic <T> reactor.core.publisher.Mono<T> bodyToMono(ParameterizedTypeReference<T> typeReference)
ServerRequestMono.bodyToMono in interface ServerRequestT - the element typetypeReference - a type reference describing the expected response request typeTpublic <T> reactor.core.publisher.Flux<T> bodyToFlux(java.lang.Class<? extends T> elementClass)
ServerRequestFlux.bodyToFlux in interface ServerRequestT - the element typeelementClass - the class of element in the Fluxpublic <T> reactor.core.publisher.Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference)
ServerRequestFlux.bodyToFlux in interface ServerRequestT - the element typetypeReference - a type reference describing the expected request body typeTpublic java.util.Optional<java.lang.Object> attribute(java.lang.String name)
ServerRequestattribute in interface ServerRequestname - the attribute namepublic java.util.Map<java.lang.String,java.lang.Object> attributes()
ServerRequestattributes in interface ServerRequestpublic java.util.Optional<java.lang.String> queryParam(java.lang.String name)
ServerRequestqueryParam in interface ServerRequestname - the parameter namepublic MultiValueMap<java.lang.String,java.lang.String> queryParams()
ServerRequestqueryParams in interface ServerRequestpublic java.lang.String pathVariable(java.lang.String name)
ServerRequestpathVariable in interface ServerRequestname - the variable namepublic java.util.Map<java.lang.String,java.lang.String> pathVariables()
ServerRequestpathVariables in interface ServerRequestpublic reactor.core.publisher.Mono<WebSession> session()
ServerRequestsession in interface ServerRequestpublic reactor.core.publisher.Mono<? extends java.security.Principal> principal()
ServerRequestprincipal in interface ServerRequestpublic reactor.core.publisher.Mono<MultiValueMap<java.lang.String,java.lang.String>> formData()
ServerRequest"application/x-www-form-urlencoded" or an empty map otherwise.
Note: calling this method causes the request body to
be read and parsed in full and the resulting MultiValueMap is
cached so that this method is safe to call more than once.
formData in interface ServerRequestpublic reactor.core.publisher.Mono<MultiValueMap<java.lang.String,Part>> multipartData()
ServerRequest"multipart/form-data" or an empty map otherwise.
Note: calling this method causes the request body to
be read and parsed in full and the resulting MultiValueMap is
cached so that this method is safe to call more than once.
multipartData in interface ServerRequest