public class ServerWebExchangeDecorator extends Object implements ServerWebExchange
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.
ServerWebExchange.mutate()
ServerWebExchange.Builder
Modifier | Constructor and Description |
---|---|
protected |
ServerWebExchangeDecorator(ServerWebExchange delegate) |
Modifier and Type | Method and Description |
---|---|
void |
addUrlTransformer(Function<String,String> transformer)
Register an additional URL transformation function for use with
ServerWebExchange.transformUrl(java.lang.String) . |
boolean |
checkNotModified(Instant lastModified)
An overloaded variant of
ServerWebExchange.checkNotModified(String, Instant) with
a last-modified timestamp only. |
boolean |
checkNotModified(String etag)
An overloaded variant of
ServerWebExchange.checkNotModified(String, Instant) with
an ETag (entity tag) value only. |
boolean |
checkNotModified(String etag,
Instant lastModified)
Check whether the requested resource has been modified given the supplied
ETag (entity tag) and last-modified timestamp as determined by
the application. |
ApplicationContext |
getApplicationContext()
Return the
ApplicationContext associated with the web application,
if it was initialized with one via
WebHttpHandlerBuilder.applicationContext(ApplicationContext) . |
Map<String,Object> |
getAttributes()
Return a mutable map of request attributes for the current exchange.
|
ServerWebExchange |
getDelegate() |
reactor.core.publisher.Mono<MultiValueMap<String,String>> |
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. |
LocaleContext |
getLocaleContext()
Return the
LocaleContext using the configured
LocaleContextResolver . |
reactor.core.publisher.Mono<MultiValueMap<String,Part>> |
getMultipartData()
Return the parts of a multipart request if the Content-Type is
"multipart/form-data" or an empty map otherwise. |
<T extends Principal> |
getPrincipal()
Return the authenticated user for the request, if any.
|
ServerHttpRequest |
getRequest()
Return the current HTTP request.
|
ServerHttpResponse |
getResponse()
Return the current HTTP response.
|
reactor.core.publisher.Mono<WebSession> |
getSession()
Return the web session for the current request.
|
boolean |
isNotModified()
Returns
true if the one of the checkNotModified methods
in this contract were used and they returned true. |
String |
toString() |
String |
transformUrl(String url)
Transform the given url according to the registered transformation function(s).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAttribute, getAttributeOrDefault, getRequiredAttribute, mutate
protected ServerWebExchangeDecorator(ServerWebExchange delegate)
public ServerWebExchange getDelegate()
public ServerHttpRequest getRequest()
ServerWebExchange
getRequest
in interface ServerWebExchange
public ServerHttpResponse getResponse()
ServerWebExchange
getResponse
in interface ServerWebExchange
public Map<String,Object> getAttributes()
ServerWebExchange
getAttributes
in interface ServerWebExchange
public reactor.core.publisher.Mono<WebSession> getSession()
ServerWebExchange
WebSession
for more details.getSession
in interface ServerWebExchange
public <T extends Principal> reactor.core.publisher.Mono<T> getPrincipal()
ServerWebExchange
getPrincipal
in interface ServerWebExchange
public LocaleContext getLocaleContext()
ServerWebExchange
LocaleContext
using the configured
LocaleContextResolver
.getLocaleContext
in interface ServerWebExchange
public ApplicationContext getApplicationContext()
ServerWebExchange
ApplicationContext
associated with the web application,
if it was initialized with one via
WebHttpHandlerBuilder.applicationContext(ApplicationContext)
.getApplicationContext
in interface ServerWebExchange
WebHttpHandlerBuilder.applicationContext(ApplicationContext)
public reactor.core.publisher.Mono<MultiValueMap<String,String>> getFormData()
ServerWebExchange
"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.
getFormData
in interface ServerWebExchange
public reactor.core.publisher.Mono<MultiValueMap<String,Part>> getMultipartData()
ServerWebExchange
"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.
getMultipartData
in interface ServerWebExchange
public boolean isNotModified()
ServerWebExchange
true
if the one of the checkNotModified
methods
in this contract were used and they returned true.isNotModified
in interface ServerWebExchange
public boolean checkNotModified(Instant lastModified)
ServerWebExchange
ServerWebExchange.checkNotModified(String, Instant)
with
a last-modified timestamp only.checkNotModified
in interface ServerWebExchange
lastModified
- the last-modified timepublic boolean checkNotModified(String etag)
ServerWebExchange
ServerWebExchange.checkNotModified(String, Instant)
with
an ETag
(entity tag) value only.checkNotModified
in interface ServerWebExchange
etag
- the entity tag for the underlying resource.public boolean checkNotModified(@Nullable String etag, Instant lastModified)
ServerWebExchange
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
ServerWebExchange.checkNotModified(Instant)
.
checkNotModified
in interface ServerWebExchange
etag
- the entity tag that the application determined for the
underlying resource. This parameter will be padded with quotes (")
if necessary.lastModified
- the last-modified timestamp that the application
determined for the underlying resourcepublic String transformUrl(String url)
ServerWebExchange
url
, though additional
transformation functions can by registered with ServerWebExchange.addUrlTransformer(java.util.function.Function<java.lang.String, java.lang.String>)
transformUrl
in interface ServerWebExchange
url
- the URL to transformpublic void addUrlTransformer(Function<String,String> transformer)
ServerWebExchange
ServerWebExchange.transformUrl(java.lang.String)
.
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.
addUrlTransformer
in interface ServerWebExchange
transformer
- a URL transformation function to add