Class ServerRequestWrapper
- All Implemented Interfaces:
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.- Since:
- 5.0
- Author:
- Arjen Poutsma
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Implementation of theHeaders
interface that can be subclassed to adapt the headers in ahandler filter function
.Nested classes/interfaces inherited from interface org.springframework.web.reactive.function.server.ServerRequest
ServerRequest.Builder, ServerRequest.Headers
-
Constructor Summary
ConstructorDescriptionServerRequestWrapper
(ServerRequest delegate) Create a newServerRequestWrapper
that wraps the given request. -
Method Summary
Modifier and TypeMethodDescriptionGet the request attribute value if present.Get a mutable map of request attributes.<T> reactor.core.publisher.Mono<T>
Bind to this request and return an instance of the given type.<T> reactor.core.publisher.Mono<T>
bind
(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) Bind to this request and return an instance of the given type.<T> T
body
(BodyExtractor<T, ? super ServerHttpRequest> extractor) Extract the body with the givenBodyExtractor
.<T> T
body
(BodyExtractor<T, ? super ServerHttpRequest> extractor, Map<String, Object> hints) Extract the body with the givenBodyExtractor
and hints.<T> reactor.core.publisher.Flux<T>
bodyToFlux
(Class<? extends T> elementClass) Extract the body to aFlux
.<T> reactor.core.publisher.Flux<T>
bodyToFlux
(ParameterizedTypeReference<T> typeReference) Extract the body to aFlux
.<T> reactor.core.publisher.Mono<T>
bodyToMono
(Class<? extends T> elementClass) Extract the body to aMono
.<T> reactor.core.publisher.Mono<T>
bodyToMono
(ParameterizedTypeReference<T> typeReference) Extract the body to aMono
.cookies()
Get the cookies of this request.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.headers()
Get the headers of this request.Get the local address to which this request is connected, if available.Get the readers used to convert the body of this request.method()
Get the HTTP method.Deprecated.reactor.core.publisher.Mono<MultiValueMap<String,
Part>> Get the parts of a multipart request if the Content-Type is"multipart/form-data"
or an empty map otherwise.path()
Get the request path.Deprecated.pathVariable
(String name) Get the path variable with the given name, if present.Get all path variables for this request.reactor.core.publisher.Mono<? extends Principal>
Get the authenticated user for the request, if any.queryParam
(String name) Get the first query parameter with the given name, if present.Get all query parameters for this request.Get the remote address to which this request is connected, if available.request()
Return the wrapped request.Get the request path as aPathContainer
.reactor.core.publisher.Mono<WebSession>
session()
Get the web session for this request.uri()
Get the request URI.Get aUriBuilderComponents
from the URI associated with thisServerRequest
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.reactive.function.server.ServerRequest
checkNotModified, checkNotModified, checkNotModified
-
Constructor Details
-
ServerRequestWrapper
Create a newServerRequestWrapper
that wraps the given request.- Parameters:
delegate
- the request to wrap
-
-
Method Details
-
request
Return the wrapped request. -
method
Description copied from interface:ServerRequest
Get the HTTP method.- Specified by:
method
in interfaceServerRequest
-
methodName
Deprecated.Description copied from interface:ServerRequest
Get the name of the HTTP method.- Specified by:
methodName
in interfaceServerRequest
- Returns:
- the HTTP method as a String
-
uri
Description copied from interface:ServerRequest
Get the request URI.- Specified by:
uri
in interfaceServerRequest
-
uriBuilder
Description copied from interface:ServerRequest
Get aUriBuilderComponents
from the URI associated with thisServerRequest
.Note: as of 5.1 this method ignores
"Forwarded"
and"X-Forwarded-*"
headers that specify the client-originated address. Consider using theForwardedHeaderFilter
to extract and use, or to discard such headers.- Specified by:
uriBuilder
in interfaceServerRequest
- Returns:
- a URI builder
-
path
Description copied from interface:ServerRequest
Get the request path.- Specified by:
path
in interfaceServerRequest
-
pathContainer
Deprecated.Description copied from interface:ServerRequest
Get the request path as aPathContainer
.- Specified by:
pathContainer
in interfaceServerRequest
-
requestPath
Description copied from interface:ServerRequest
Get the request path as aPathContainer
.- Specified by:
requestPath
in interfaceServerRequest
-
headers
Description copied from interface:ServerRequest
Get the headers of this request.- Specified by:
headers
in interfaceServerRequest
-
cookies
Description copied from interface:ServerRequest
Get the cookies of this request.- Specified by:
cookies
in interfaceServerRequest
-
remoteAddress
Description copied from interface:ServerRequest
Get the remote address to which this request is connected, if available.- Specified by:
remoteAddress
in interfaceServerRequest
-
localAddress
Description copied from interface:ServerRequest
Get the local address to which this request is connected, if available.- Specified by:
localAddress
in interfaceServerRequest
-
messageReaders
Description copied from interface:ServerRequest
Get the readers used to convert the body of this request.- Specified by:
messageReaders
in interfaceServerRequest
-
body
Description copied from interface:ServerRequest
Extract the body with the givenBodyExtractor
.- Specified by:
body
in interfaceServerRequest
- Type Parameters:
T
- the type of the body returned- Parameters:
extractor
- theBodyExtractor
that reads from the request- Returns:
- the extracted body
- See Also:
-
body
Description copied from interface:ServerRequest
Extract the body with the givenBodyExtractor
and hints.- Specified by:
body
in interfaceServerRequest
- Type Parameters:
T
- the type of the body returned- Parameters:
extractor
- theBodyExtractor
that reads from the requesthints
- the map of hints likeJackson2CodecSupport.JSON_VIEW_HINT
to use to customize body extraction- Returns:
- the extracted body
-
bodyToMono
Description copied from interface:ServerRequest
Extract the body to aMono
.- Specified by:
bodyToMono
in interfaceServerRequest
- Type Parameters:
T
- the element type- Parameters:
elementClass
- the class of element in theMono
- Returns:
- the body as a mono
-
bodyToMono
Description copied from interface:ServerRequest
Extract the body to aMono
.- Specified by:
bodyToMono
in interfaceServerRequest
- Type Parameters:
T
- the element type- Parameters:
typeReference
- a type reference describing the expected response request type- Returns:
- a mono containing the body of the given type
T
-
bodyToFlux
Description copied from interface:ServerRequest
Extract the body to aFlux
.- Specified by:
bodyToFlux
in interfaceServerRequest
- Type Parameters:
T
- the element type- Parameters:
elementClass
- the class of element in theFlux
- Returns:
- the body as a flux
-
bodyToFlux
Description copied from interface:ServerRequest
Extract the body to aFlux
.- Specified by:
bodyToFlux
in interfaceServerRequest
- Type Parameters:
T
- the element type- Parameters:
typeReference
- a type reference describing the expected request body type- Returns:
- a flux containing the body of the given type
T
-
bind
Description copied from interface:ServerRequest
Bind to this request and return an instance of the given type.- Specified by:
bind
in interfaceServerRequest
- Type Parameters:
T
- the type to bind to- Parameters:
bindType
- the type of class to bind this request to- Returns:
- a mono containing either a constructed and bound instance of
bindType
, or aBindException
in case of binding errors
-
bind
public <T> reactor.core.publisher.Mono<T> bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) Description copied from interface:ServerRequest
Bind to this request and return an instance of the given type.- Specified by:
bind
in interfaceServerRequest
- Type Parameters:
T
- the type to bind to- Parameters:
bindType
- the type of class to bind this request todataBinderCustomizer
- used to customize the data binder, e.g. set (dis)allowed fields- Returns:
- a mono containing either a constructed and bound instance of
bindType
, or aBindException
in case of binding errors
-
attribute
Description copied from interface:ServerRequest
Get the request attribute value if present.- Specified by:
attribute
in interfaceServerRequest
- Parameters:
name
- the attribute name- Returns:
- the attribute value
-
attributes
Description copied from interface:ServerRequest
Get a mutable map of request attributes.- Specified by:
attributes
in interfaceServerRequest
- Returns:
- the request attributes
-
queryParam
Description copied from interface:ServerRequest
Get the first query parameter with the given name, if present.- Specified by:
queryParam
in interfaceServerRequest
- Parameters:
name
- the parameter name- Returns:
- the parameter value
-
queryParams
Description copied from interface:ServerRequest
Get all query parameters for this request.- Specified by:
queryParams
in interfaceServerRequest
-
pathVariable
Description copied from interface:ServerRequest
Get the path variable with the given name, if present.- Specified by:
pathVariable
in interfaceServerRequest
- Parameters:
name
- the variable name- Returns:
- the variable value
-
pathVariables
Description copied from interface:ServerRequest
Get all path variables for this request.- Specified by:
pathVariables
in interfaceServerRequest
-
session
Description copied from interface:ServerRequest
Get the web session for this request.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.
- Specified by:
session
in interfaceServerRequest
-
principal
Description copied from interface:ServerRequest
Get the authenticated user for the request, if any.- Specified by:
principal
in interfaceServerRequest
-
formData
Description copied from interface:ServerRequest
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.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.- Specified by:
formData
in interfaceServerRequest
-
multipartData
Description copied from interface:ServerRequest
Get the parts of a multipart request if the Content-Type is"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.- Specified by:
multipartData
in interfaceServerRequest
-
exchange
Description copied from interface:ServerRequest
Get the web exchange that this request is based on.Note: Manipulating the exchange directly (instead of using the methods provided on
ServerRequest
andServerResponse
) can lead to irregular results.- Specified by:
exchange
in interfaceServerRequest
-