org.springframework.web.reactive.function.server.support

## Class ServerRequestWrapper

- java.lang.Object
- - org.springframework.web.reactive.function.server.support.ServerRequestWrapper

All Implemented Interfaces:
  ServerRequest

    public class ServerRequestWrapper
    extends Object
    implements ServerRequest

Implementation of the `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

Nested Classes
`static class` `ServerRequestWrapper.HeadersWrapper` Implementation of the `Headers` interface that can be subclassed to adapt the headers in a `handler filter function`.

### Nested classes/interfaces inherited from interface org.springframework.web.reactive.function.server.ServerRequest

`ServerRequest.Builder, ServerRequest.Headers`

### Constructor Summary

Constructors
Constructor and Description
`ServerRequestWrapper(ServerRequest delegate)` Create a new `ServerRequestWrapper` that wraps the given request.

### Method Summary

All Methods Instance Methods Concrete Methods
`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 org.springframework.http.server.reactive.ServerHttpRequest> extractor)` Extract the body with the given `BodyExtractor`.
`<T> T` `body(BodyExtractor<T,? super org.springframework.http.server.reactive.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(org.springframework.core.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(org.springframework.core.ParameterizedTypeReference<T> typeReference)` Extract the body to a `Mono`.
`org.springframework.util.MultiValueMap<String,org.springframework.http.HttpCookie>` `cookies()` Get the cookies of this request.
`org.springframework.web.server.ServerWebExchange` `exchange()` Get the web exchange that this request is based on.
`reactor.core.publisher.Mono<org.springframework.util.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<org.springframework.http.codec.HttpMessageReader<?>>` `messageReaders()` Get the readers used to convert the body of this request.
`org.springframework.http.HttpMethod` `method()` Get the HTTP method.
`String` `methodName()` Get the name of the HTTP method.
`reactor.core.publisher.Mono<org.springframework.util.MultiValueMap<String,org.springframework.http.codec.multipart.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.
`org.springframework.http.server.PathContainer` `pathContainer()` Get the request path as a `PathContainer`.
`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.
`org.springframework.util.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.
`reactor.core.publisher.Mono<org.springframework.web.server.WebSession>` `session()` Get the web session for this request.
`URI` `uri()` Get the request URI.
`org.springframework.web.util.UriBuilder` `uriBuilder()` Get a `UriBuilderComponents` from the URI associated with this `ServerRequest`.

### 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, create, from`

### Constructor Detail

#### ServerRequestWrapper

    public ServerRequestWrapper(ServerRequest delegate)

Create a new `ServerRequestWrapper` that wraps the given request.

Parameters:
  `delegate` - the request to wrap

### Method Detail

#### request

    public ServerRequest request()

Return the wrapped request.

#### method

    public org.springframework.http.HttpMethod method()

Description copied from interface: `ServerRequest`
Get the HTTP method.

Specified by:
  `method` in interface `ServerRequest`
Returns:
  the HTTP method as an HttpMethod enum value, or `null` if not resolvable (e.g. in case of a non-standard HTTP method)

#### methodName

    public String methodName()

Description copied from interface: `ServerRequest`
Get the name of the HTTP method.

Specified by:
  `methodName` in interface `ServerRequest`
Returns:
  the HTTP method as a String

#### uri

    public URI uri()

Description copied from interface: `ServerRequest`
Get the request URI.

Specified by:
  `uri` in interface `ServerRequest`

#### uriBuilder

    public org.springframework.web.util.UriBuilder uriBuilder()

Description copied from interface: `ServerRequest`
Get a `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.

Specified by:
  `uriBuilder` in interface `ServerRequest`
Returns:
  a URI builder

#### path

    public String path()

Description copied from interface: `ServerRequest`
Get the request path.

Specified by:
  `path` in interface `ServerRequest`

#### pathContainer

    public org.springframework.http.server.PathContainer pathContainer()

Description copied from interface: `ServerRequest`
Get the request path as a `PathContainer`.

Specified by:
  `pathContainer` in interface `ServerRequest`

#### headers

    public ServerRequest.Headers headers()

Description copied from interface: `ServerRequest`
Get the headers of this request.

Specified by:
  `headers` in interface `ServerRequest`

#### cookies

    public org.springframework.util.MultiValueMap<String,org.springframework.http.HttpCookie> cookies()

Description copied from interface: `ServerRequest`
Get the cookies of this request.

Specified by:
  `cookies` in interface `ServerRequest`

#### remoteAddress

    public Optional<InetSocketAddress> remoteAddress()

Description copied from interface: `ServerRequest`
Get the remote address to which this request is connected, if available.

Specified by:
  `remoteAddress` in interface `ServerRequest`

#### localAddress

    public Optional<InetSocketAddress> localAddress()

Description copied from interface: `ServerRequest`
Get the local address to which this request is connected, if available.

Specified by:
  `localAddress` in interface `ServerRequest`

#### messageReaders

    public List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders()

Description copied from interface: `ServerRequest`
Get the readers used to convert the body of this request.

Specified by:
  `messageReaders` in interface `ServerRequest`

#### body

    public <T> T body(BodyExtractor<T,? super org.springframework.http.server.reactive.ServerHttpRequest> extractor)

Description copied from interface: `ServerRequest`
Extract the body with the given `BodyExtractor`.

Specified by:
  `body` in interface `ServerRequest`
Type Parameters:
  `T` - the type of the body returned
Parameters:
  `extractor` - the `BodyExtractor` that reads from the request
Returns:
  the extracted body
See Also:
  `ServerRequest.body(BodyExtractor, Map)`

#### body

    public <T> T body(BodyExtractor<T,? super org.springframework.http.server.reactive.ServerHttpRequest> extractor,
                      Map<String,Object> hints)

Description copied from interface: `ServerRequest`
Extract the body with the given `BodyExtractor` and hints.

Specified by:
  `body` in interface `ServerRequest`
Type Parameters:
  `T` - the type of the body returned
Parameters:
  `extractor` - the `BodyExtractor` that reads from the request
  `hints` - the map of hints like `Jackson2CodecSupport.JSON_VIEW_HINT` to use to customize body extraction
Returns:
  the extracted body

#### bodyToMono

    public <T> reactor.core.publisher.Mono<T> bodyToMono(Class<? extends T> elementClass)

Description copied from interface: `ServerRequest`
Extract the body to a `Mono`.

Specified by:
  `bodyToMono` in interface `ServerRequest`
Type Parameters:
  `T` - the element type
Parameters:
  `elementClass` - the class of element in the `Mono`
Returns:
  the body as a mono

#### bodyToMono

    public <T> reactor.core.publisher.Mono<T> bodyToMono(org.springframework.core.ParameterizedTypeReference<T> typeReference)

Description copied from interface: `ServerRequest`
Extract the body to a `Mono`.

Specified by:
  `bodyToMono` in interface `ServerRequest`
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

    public <T> reactor.core.publisher.Flux<T> bodyToFlux(Class<? extends T> elementClass)

Description copied from interface: `ServerRequest`
Extract the body to a `Flux`.

Specified by:
  `bodyToFlux` in interface `ServerRequest`
Type Parameters:
  `T` - the element type
Parameters:
  `elementClass` - the class of element in the `Flux`
Returns:
  the body as a flux

#### bodyToFlux

    public <T> reactor.core.publisher.Flux<T> bodyToFlux(org.springframework.core.ParameterizedTypeReference<T> typeReference)

Description copied from interface: `ServerRequest`
Extract the body to a `Flux`.

Specified by:
  `bodyToFlux` in interface `ServerRequest`
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`

#### attribute

    public Optional<Object> attribute(String name)

Description copied from interface: `ServerRequest`
Get the request attribute value if present.

Specified by:
  `attribute` in interface `ServerRequest`
Parameters:
  `name` - the attribute name
Returns:
  the attribute value

#### attributes

    public Map<String,Object> attributes()

Description copied from interface: `ServerRequest`
Get a mutable map of request attributes.

Specified by:
  `attributes` in interface `ServerRequest`
Returns:
  the request attributes

#### queryParam

    public Optional<String> queryParam(String name)

Description copied from interface: `ServerRequest`
Get the first query parameter with the given name, if present.

Specified by:
  `queryParam` in interface `ServerRequest`
Parameters:
  `name` - the parameter name
Returns:
  the parameter value

#### queryParams

    public org.springframework.util.MultiValueMap<String,String> queryParams()

Description copied from interface: `ServerRequest`
Get all query parameters for this request.

Specified by:
  `queryParams` in interface `ServerRequest`

#### pathVariable

    public String pathVariable(String name)

Description copied from interface: `ServerRequest`
Get the path variable with the given name, if present.

Specified by:
  `pathVariable` in interface `ServerRequest`
Parameters:
  `name` - the variable name
Returns:
  the variable value

#### pathVariables

    public Map<String,String> pathVariables()

Description copied from interface: `ServerRequest`
Get all path variables for this request.

Specified by:
  `pathVariables` in interface `ServerRequest`

#### session

    public reactor.core.publisher.Mono<org.springframework.web.server.WebSession> 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 interface `ServerRequest`

#### principal

    public reactor.core.publisher.Mono<? extends Principal> principal()

Description copied from interface: `ServerRequest`
Get the authenticated user for the request, if any.

Specified by:
  `principal` in interface `ServerRequest`

#### formData

    public reactor.core.publisher.Mono<org.springframework.util.MultiValueMap<String,String>> 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 interface `ServerRequest`

#### multipartData

    public reactor.core.publisher.Mono<org.springframework.util.MultiValueMap<String,org.springframework.http.codec.multipart.Part>> 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 interface `ServerRequest`

#### exchange

    public org.springframework.web.server.ServerWebExchange 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` and `ServerResponse`) can lead to irregular results.

Specified by:
  `exchange` in interface `ServerRequest`