public class ServerRequestWrapper extends 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.Builder, ServerRequest.Headers
Constructor and Description |
---|
ServerRequestWrapper(ServerRequest delegate)
Create a new
ServerRequestWrapper that wraps the given request. |
Modifier and Type | Method and Description |
---|---|
Optional<Object> |
attribute(String name)
Get the request attribute value if present.
|
Map<String,Object> |
attributes()
Get 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,
Map<String,Object> hints)
Extract the body with the given
BodyExtractor and hints. |
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(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(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<String,HttpCookie> |
cookies()
Get the cookies of this request.
|
ServerWebExchange |
exchange()
Get the web exchange that this request is based on.
|
reactor.core.publisher.Mono<MultiValueMap<String,String>> |
formData()
Get 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()
Get the headers of this request.
|
Optional<InetSocketAddress> |
localAddress()
Get the local address to which this request is connected, if available.
|
List<HttpMessageReader<?>> |
messageReaders()
Get the readers used to convert the body of this request.
|
HttpMethod |
method()
Get the HTTP method.
|
String |
methodName()
Get the name of the HTTP method.
|
reactor.core.publisher.Mono<MultiValueMap<String,Part>> |
multipartData()
Get the parts of a multipart request if the Content-Type is
"multipart/form-data" or an empty map otherwise. |
String |
path()
Get the request path.
|
PathContainer |
pathContainer()
Deprecated.
|
String |
pathVariable(String name)
Get the path variable with the given name, if present.
|
Map<String,String> |
pathVariables()
Get all path variables for this request.
|
reactor.core.publisher.Mono<? extends Principal> |
principal()
Get the authenticated user for the request, if any.
|
Optional<String> |
queryParam(String name)
Get the first query parameter with the given name, if present.
|
MultiValueMap<String,String> |
queryParams()
Get all query parameters for this request.
|
Optional<InetSocketAddress> |
remoteAddress()
Get the remote address to which this request is connected, if available.
|
ServerRequest |
request()
Return the wrapped request.
|
RequestPath |
requestPath()
Get the request path as a
PathContainer . |
reactor.core.publisher.Mono<WebSession> |
session()
Get the web session for this request.
|
URI |
uri()
Get the request URI.
|
UriBuilder |
uriBuilder()
Get a
UriBuilderComponents from the URI associated with this
ServerRequest . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkNotModified, checkNotModified, checkNotModified, create, from
public ServerRequestWrapper(ServerRequest delegate)
ServerRequestWrapper
that wraps the given request.delegate
- the request to wrappublic ServerRequest request()
public HttpMethod method()
ServerRequest
method
in interface ServerRequest
null
if not resolvable (e.g. in case of a non-standard HTTP method)public String methodName()
ServerRequest
methodName
in interface ServerRequest
public URI uri()
ServerRequest
uri
in interface ServerRequest
public UriBuilder uriBuilder()
ServerRequest
UriBuilderComponents
from the URI associated with this
ServerRequest
.
Note: as of 5.1 this method ignores "Forwarded"
and "X-Forwarded-*"
headers that specify the
client-originated address. Consider using the ForwardedHeaderFilter
to extract and use, or to discard such headers.
uriBuilder
in interface ServerRequest
public String path()
ServerRequest
path
in interface ServerRequest
@Deprecated public PathContainer pathContainer()
ServerRequest
PathContainer
.pathContainer
in interface ServerRequest
public RequestPath requestPath()
ServerRequest
PathContainer
.requestPath
in interface ServerRequest
public ServerRequest.Headers headers()
ServerRequest
headers
in interface ServerRequest
public MultiValueMap<String,HttpCookie> cookies()
ServerRequest
cookies
in interface ServerRequest
public Optional<InetSocketAddress> remoteAddress()
ServerRequest
remoteAddress
in interface ServerRequest
public Optional<InetSocketAddress> localAddress()
ServerRequest
localAddress
in interface ServerRequest
public List<HttpMessageReader<?>> messageReaders()
ServerRequest
messageReaders
in interface ServerRequest
public <T> T body(BodyExtractor<T,? super ServerHttpRequest> extractor)
ServerRequest
BodyExtractor
.body
in interface ServerRequest
T
- 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, Map<String,Object> hints)
ServerRequest
BodyExtractor
and hints.body
in interface ServerRequest
T
- 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(Class<? extends T> elementClass)
ServerRequest
Mono
.bodyToMono
in interface ServerRequest
T
- the element typeelementClass
- the class of element in the Mono
public <T> reactor.core.publisher.Mono<T> bodyToMono(ParameterizedTypeReference<T> typeReference)
ServerRequest
Mono
.bodyToMono
in interface ServerRequest
T
- the element typetypeReference
- a type reference describing the expected response request typeT
public <T> reactor.core.publisher.Flux<T> bodyToFlux(Class<? extends T> elementClass)
ServerRequest
Flux
.bodyToFlux
in interface ServerRequest
T
- the element typeelementClass
- the class of element in the Flux
public <T> reactor.core.publisher.Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference)
ServerRequest
Flux
.bodyToFlux
in interface ServerRequest
T
- the element typetypeReference
- a type reference describing the expected request body typeT
public Optional<Object> attribute(String name)
ServerRequest
attribute
in interface ServerRequest
name
- the attribute namepublic Map<String,Object> attributes()
ServerRequest
attributes
in interface ServerRequest
public Optional<String> queryParam(String name)
ServerRequest
queryParam
in interface ServerRequest
name
- the parameter namepublic MultiValueMap<String,String> queryParams()
ServerRequest
queryParams
in interface ServerRequest
public String pathVariable(String name)
ServerRequest
pathVariable
in interface ServerRequest
name
- the variable namepublic Map<String,String> pathVariables()
ServerRequest
pathVariables
in interface ServerRequest
public reactor.core.publisher.Mono<WebSession> session()
ServerRequest
Always guaranteed to return an instance either matching the session id requested by the client, or with a new session id either because the client did not specify one or because the underlying session had expired.
Use of this method does not automatically create a session.
session
in interface ServerRequest
public reactor.core.publisher.Mono<? extends Principal> principal()
ServerRequest
principal
in interface ServerRequest
public reactor.core.publisher.Mono<MultiValueMap<String,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 ServerRequest
public reactor.core.publisher.Mono<MultiValueMap<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
public ServerWebExchange exchange()
ServerRequest
Note: Manipulating the exchange directly (instead of using the methods provided on
ServerRequest
and ServerResponse
) can lead to irregular results.
exchange
in interface ServerRequest