public interface ServerWebExchange
Modifier and Type | Interface and Description |
---|---|
static interface |
ServerWebExchange.Builder
Builder for mutating an existing
ServerWebExchange . |
Modifier and Type | Method and Description |
---|---|
void |
addUrlTransformer(java.util.function.Function<java.lang.String,java.lang.String> transformer)
Register an additional URL transformation function for use with
transformUrl(java.lang.String) . |
boolean |
checkNotModified(java.time.Instant lastModified)
An overloaded variant of
checkNotModified(String, Instant) with
a last-modified timestamp only. |
boolean |
checkNotModified(java.lang.String etag)
An overloaded variant of
checkNotModified(String, Instant) with
an ETag (entity tag) value only. |
boolean |
checkNotModified(java.lang.String etag,
java.time.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 . |
default <T> T |
getAttribute(java.lang.String name)
Return the request attribute value if present.
|
default <T> T |
getAttributeOrDefault(java.lang.String name,
T defaultValue)
Return the request attribute value, or a default, fallback value.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Return a mutable map of request attributes for the current exchange.
|
reactor.core.publisher.Mono<MultiValueMap<java.lang.String,java.lang.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<java.lang.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 java.security.Principal> |
getPrincipal()
Return the authenticated user for the request, if any.
|
ServerHttpRequest |
getRequest()
Return the current HTTP request.
|
default <T> T |
getRequiredAttribute(java.lang.String name)
Return the request attribute value or if not present raise an
IllegalArgumentException . |
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. |
default ServerWebExchange.Builder |
mutate()
Return a builder to mutate properties of this exchange by wrapping it
with
ServerWebExchangeDecorator and returning either mutated
values or delegating back to this instance. |
java.lang.String |
transformUrl(java.lang.String url)
Transform the given url according to the registered transformation function(s).
|
ServerHttpRequest getRequest()
ServerHttpResponse getResponse()
java.util.Map<java.lang.String,java.lang.Object> getAttributes()
@Nullable default <T> T getAttribute(java.lang.String name)
T
- the attribute typename
- the attribute namedefault <T> T getRequiredAttribute(java.lang.String name)
IllegalArgumentException
.T
- the attribute typename
- the attribute namedefault <T> T getAttributeOrDefault(java.lang.String name, T defaultValue)
T
- the attribute typename
- the attribute namedefaultValue
- a default value to return insteadreactor.core.publisher.Mono<WebSession> getSession()
WebSession
for more details.<T extends java.security.Principal> reactor.core.publisher.Mono<T> getPrincipal()
reactor.core.publisher.Mono<MultiValueMap<java.lang.String,java.lang.String>> getFormData()
"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.
reactor.core.publisher.Mono<MultiValueMap<java.lang.String,Part>> getMultipartData()
"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.
LocaleContext getLocaleContext()
LocaleContext
using the configured
LocaleContextResolver
.@Nullable ApplicationContext getApplicationContext()
ApplicationContext
associated with the web application,
if it was initialized with one via
WebHttpHandlerBuilder#applicationContext
.WebHttpHandlerBuilder.applicationContext(ApplicationContext)
boolean isNotModified()
true
if the one of the checkNotModified
methods
in this contract were used and they returned true.boolean checkNotModified(java.time.Instant lastModified)
checkNotModified(String, Instant)
with
a last-modified timestamp only.lastModified
- the last-modified timeboolean checkNotModified(java.lang.String etag)
checkNotModified(String, Instant)
with
an ETag
(entity tag) value only.etag
- the entity tag for the underlying resource.boolean checkNotModified(@Nullable java.lang.String etag, java.time.Instant lastModified)
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)
.
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 resourcejava.lang.String transformUrl(java.lang.String url)
url
, though additional
transformation functions can by registered with addUrlTransformer(java.util.function.Function<java.lang.String, java.lang.String>)
url
- the URL to transformvoid addUrlTransformer(java.util.function.Function<java.lang.String,java.lang.String> transformer)
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.
transformer
- a URL transformation function to adddefault ServerWebExchange.Builder mutate()
ServerWebExchangeDecorator
and returning either mutated
values or delegating back to this instance.