Top Description Fields Constructors Methods
org.springframework.web.server

public Class ServerWebExchangeDecorator

extends Object
implements ServerWebExchange
Class Inheritance
All Implemented Interfaces
org.springframework.web.server.ServerWebExchange
Known Direct Subclasses
org.springframework.web.server.DefaultServerWebExchangeBuilder.MutativeDecorator
Imports
java.security.Principal, java.time.Instant, java.util.Map, java.util.function.Function, reactor.core.publisher.Mono, org.springframework.context.ApplicationContext, org.springframework.context.i18n.LocaleContext, org.springframework.http.codec.multipart.Part, org.springframework.http.server.reactive.ServerHttpRequest, .ServerHttpResponse, org.springframework.lang.Nullable, org.springframework.util.Assert, .MultiValueMap

A convenient base class for classes that need to wrap another ServerWebExchange. Pre-implements all methods by delegating to the wrapped instance.

Note

if the purpose for using a decorator is to override properties like getPrincipal(), consider using ServerWebExchange#mutate() instead.

Author
Rossen Stoyanchev
Since
5.0
See Also
ServerWebExchange#mutate()

Field Summary

Modifier and TypeField and Description
private final ServerWebExchange

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
addUrlTransformer(Function<String, String>
a URL transformation function to add
transformer
)

Implements org.springframework.web.server.ServerWebExchange.addUrlTransformer.

Register an additional URL transformation function for use with transformUrl.
public boolean
checkNotModified(Instant
the last-modified time
lastModified
)

Implements org.springframework.web.server.ServerWebExchange.checkNotModified.

An overloaded variant of checkNotModified(String, Instant) with a last-modified timestamp only.
public boolean
checkNotModified(String
the entity tag for the underlying resource.
etag
)

Implements org.springframework.web.server.ServerWebExchange.checkNotModified.

An overloaded variant of checkNotModified(String, Instant) with an ETag (entity tag) value only.
public boolean
checkNotModified(String
the entity tag that the application determined for the underlying resource. This parameter will be padded with quotes (") if necessary.
etag
,
Instant
the last-modified timestamp that the application determined for the underlying resource
lastModified
)

Implements org.springframework.web.server.ServerWebExchange.checkNotModified.

Check whether the requested resource has been modified given the supplied ETag (entity tag) and last-modified timestamp as determined by the application.
public Mono<Void>
cleanupMultipart()

Overrides default org.springframework.web.server.ServerWebExchange.cleanupMultipart.

Cleans up any storage used for multipart handling.
public ApplicationContext
public Map<String, Object>
getAttributes()

Implements org.springframework.web.server.ServerWebExchange.getAttributes.

Return a mutable map of request attributes for the current exchange.
public ServerWebExchange
public Mono<MultiValueMap<String, String>>
getFormData()

Implements org.springframework.web.server.ServerWebExchange.getFormData.

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.
public LocaleContext
public String
getLogPrefix()

Implements org.springframework.web.server.ServerWebExchange.getLogPrefix.

Return a log message prefix to use to correlate messages for this exchange.
public Mono<MultiValueMap<String, Part>>
getMultipartData()

Implements org.springframework.web.server.ServerWebExchange.getMultipartData.

Return the parts of a multipart request if the Content-Type is "multipart/form-data" or an empty map otherwise.
public <T extends Principal> Mono<T>
getPrincipal()

Implements org.springframework.web.server.ServerWebExchange.getPrincipal.

Return the authenticated user for the request, if any.
public ServerHttpRequest
getRequest()

Implements org.springframework.web.server.ServerWebExchange.getRequest.

Return the current HTTP request.
public ServerHttpResponse
getResponse()

Implements org.springframework.web.server.ServerWebExchange.getResponse.

Return the current HTTP response.
public Mono<WebSession>
getSession()

Implements org.springframework.web.server.ServerWebExchange.getSession.

Return the web session for the current request.
public boolean
isNotModified()

Implements org.springframework.web.server.ServerWebExchange.isNotModified.

Returns true if the one of the checkNotModified methods in this contract were used and they returned true.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public String
transformUrl(String
the URL to transform
url
)

Implements org.springframework.web.server.ServerWebExchange.transformUrl.

Transform the given url according to the registered transformation function(s).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

delegateback to summary
private final ServerWebExchange delegate

Constructor Detail

ServerWebExchangeDecoratorback to summary
protected ServerWebExchangeDecorator(ServerWebExchange delegate)

Method Detail

addUrlTransformerback to summary
public void addUrlTransformer(Function<String, String> transformer)

Implements org.springframework.web.server.ServerWebExchange.addUrlTransformer.

Doc from org.springframework.web.server.ServerWebExchange.addUrlTransformer.

Register an additional URL transformation function for use with transformUrl. The given function can be used to insert an id for authentication, a nonce for CSRF protection, etc.

Note that the given function is applied after any previously registered functions.

Parameters
transformer:Function<String, String>

a URL transformation function to add

Annotations
@Override
checkNotModifiedback to summary
public boolean checkNotModified(Instant lastModified)

Implements org.springframework.web.server.ServerWebExchange.checkNotModified.

Doc from org.springframework.web.server.ServerWebExchange.checkNotModified.

An overloaded variant of checkNotModified(String, Instant) with a last-modified timestamp only.

Parameters
lastModified:Instant

the last-modified time

Returns:boolean

whether the request qualifies as not modified

Annotations
@Override
checkNotModifiedback to summary
public boolean checkNotModified(String etag)

Implements org.springframework.web.server.ServerWebExchange.checkNotModified.

Doc from org.springframework.web.server.ServerWebExchange.checkNotModified.

An overloaded variant of checkNotModified(String, Instant) with an ETag (entity tag) value only.

Parameters
etag:String

the entity tag for the underlying resource.

Returns:boolean

true if the request does not require further processing.

Annotations
@Override
checkNotModifiedback to summary
public boolean checkNotModified(String etag, Instant lastModified)

Implements org.springframework.web.server.ServerWebExchange.checkNotModified.

Doc from org.springframework.web.server.ServerWebExchange.checkNotModified.

Check whether the requested resource has been modified given the supplied ETag (entity tag) and last-modified timestamp as determined by the application. Also transparently prepares the response, setting HTTP status, and adding "ETag" and "Last-Modified" headers when applicable. This method works with conditional GET/HEAD requests as well as with conditional POST/PUT/DELETE requests.

Note

The HTTP specification recommends setting both ETag and Last-Modified values, but you can also use #checkNotModified(String) or checkNotModified(Instant).

Parameters
etag:String

the entity tag that the application determined for the underlying resource. This parameter will be padded with quotes (") if necessary.

lastModified:Instant

the last-modified timestamp that the application determined for the underlying resource

Returns:boolean

true if the request does not require further processing.

Annotations
@Override
cleanupMultipartback to summary
public Mono<Void> cleanupMultipart()

Overrides default org.springframework.web.server.ServerWebExchange.cleanupMultipart.

Doc from org.springframework.web.server.ServerWebExchange.cleanupMultipart.

Cleans up any storage used for multipart handling.

Annotations
@Override
getApplicationContextback to summary
public ApplicationContext getApplicationContext()

Implements org.springframework.web.server.ServerWebExchange.getApplicationContext.

Doc from org.springframework.web.server.ServerWebExchange.getApplicationContext.

Return the ApplicationContext associated with the web application, if it was initialized with one via org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext(ApplicationContext).

Annotations
@Override
getAttributesback to summary
public Map<String, Object> getAttributes()

Implements org.springframework.web.server.ServerWebExchange.getAttributes.

Doc from org.springframework.web.server.ServerWebExchange.getAttributes.

Return a mutable map of request attributes for the current exchange.

Annotations
@Override
getDelegateback to summary
public ServerWebExchange getDelegate()
getFormDataback to summary
public Mono<MultiValueMap<String, String>> getFormData()

Implements org.springframework.web.server.ServerWebExchange.getFormData.

Doc from org.springframework.web.server.ServerWebExchange.getFormData.

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.

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.

Annotations
@Override
getLocaleContextback to summary
public LocaleContext getLocaleContext()

Implements org.springframework.web.server.ServerWebExchange.getLocaleContext.

Doc from org.springframework.web.server.ServerWebExchange.getLocaleContext.

Return the LocaleContext using the configured org.springframework.web.server.i18n.LocaleContextResolver.

Annotations
@Override
getLogPrefixback to summary
public String getLogPrefix()

Implements org.springframework.web.server.ServerWebExchange.getLogPrefix.

Doc from org.springframework.web.server.ServerWebExchange.getLogPrefix.

Return a log message prefix to use to correlate messages for this exchange. The prefix is based on the value of the attribute LOG_ID_ATTRIBUTE along with some extra formatting so that the prefix can be conveniently prepended with no further formatting no separators required.

Returns:String

the log message prefix or an empty String if the LOG_ID_ATTRIBUTE is not set.

Annotations
@Override
getMultipartDataback to summary
public Mono<MultiValueMap<String, Part>> getMultipartData()

Implements org.springframework.web.server.ServerWebExchange.getMultipartData.

Doc from org.springframework.web.server.ServerWebExchange.getMultipartData.

Return 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.

Note

the contents of each part is not cached, and can only be read once.

Annotations
@Override
getPrincipalback to summary
public <T extends Principal> Mono<T> getPrincipal()

Implements org.springframework.web.server.ServerWebExchange.getPrincipal.

Doc from org.springframework.web.server.ServerWebExchange.getPrincipal.

Return the authenticated user for the request, if any.

Annotations
@Override
getRequestback to summary
public ServerHttpRequest getRequest()

Implements org.springframework.web.server.ServerWebExchange.getRequest.

Doc from org.springframework.web.server.ServerWebExchange.getRequest.

Return the current HTTP request.

Annotations
@Override
getResponseback to summary
public ServerHttpResponse getResponse()

Implements org.springframework.web.server.ServerWebExchange.getResponse.

Doc from org.springframework.web.server.ServerWebExchange.getResponse.

Return the current HTTP response.

Annotations
@Override
getSessionback to summary
public Mono<WebSession> getSession()

Implements org.springframework.web.server.ServerWebExchange.getSession.

Doc from org.springframework.web.server.ServerWebExchange.getSession.

Return the web session for the current request. Always guaranteed to return an instance either matching to 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. See WebSession for more details.

Annotations
@Override
isNotModifiedback to summary
public boolean isNotModified()

Implements org.springframework.web.server.ServerWebExchange.isNotModified.

Doc from org.springframework.web.server.ServerWebExchange.isNotModified.

Returns true if the one of the checkNotModified methods in this contract were used and they returned true.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
transformUrlback to summary
public String transformUrl(String url)

Implements org.springframework.web.server.ServerWebExchange.transformUrl.

Doc from org.springframework.web.server.ServerWebExchange.transformUrl.

Transform the given url according to the registered transformation function(s). By default, this method returns the given url, though additional transformation functions can be registered with addUrlTransformer

Parameters
url:String

the URL to transform

Returns:String

the transformed URL

Annotations
@Override