Class ServerWebExchangeContextFilter
java.lang.Object
org.springframework.web.filter.reactive.ServerWebExchangeContextFilter
- All Implemented Interfaces:
WebFilter
Inserts an attribute in the Reactor
Context
that makes the current
ServerWebExchange
available under the attribute name
EXCHANGE_CONTEXT_ATTRIBUTE
. This is useful for access to the
exchange without explicitly passing it to components that participate in
request processing.
The convenience method getExchange(ContextView)
looks up the exchange.
- Since:
- 5.2
- Author:
- Rossen Stoyanchev
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Attribute name under which the exchange is saved in the context. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>
filter
(ServerWebExchange exchange, WebFilterChain chain) Process the Web request and (optionally) delegate to the nextWebFilter
through the givenWebFilterChain
.static Optional<ServerWebExchange>
get
(reactor.util.context.Context context) Deprecated, for removal: This API element is subject to removal in a future version.static Optional<ServerWebExchange>
getExchange
(reactor.util.context.ContextView contextView) Access theServerWebExchange
from a ReactorContextView
, if available, which is generally the case whenServerWebExchangeContextFilter
is present in the filter chain.
-
Field Details
-
EXCHANGE_CONTEXT_ATTRIBUTE
Attribute name under which the exchange is saved in the context.
-
-
Constructor Details
-
ServerWebExchangeContextFilter
public ServerWebExchangeContextFilter()
-
-
Method Details
-
filter
Description copied from interface:WebFilter
Process the Web request and (optionally) delegate to the nextWebFilter
through the givenWebFilterChain
. -
getExchange
Access theServerWebExchange
from a ReactorContextView
, if available, which is generally the case whenServerWebExchangeContextFilter
is present in the filter chain.- Parameters:
contextView
- the contextView to get the exchange from- Returns:
- an
Optional
with the exchange if found - Since:
- 6.0.6
-
get
@Deprecated(since="6.0.6", forRemoval=true) public static Optional<ServerWebExchange> get(reactor.util.context.Context context) Deprecated, for removal: This API element is subject to removal in a future version.in favor of usinggetExchange(ContextView)
which accepts aContextView
instead ofContext
, reflecting the fact that theContextView
is needed only for reading.Access theServerWebExchange
from a ReactorContext
, if available, which is generally the case whenServerWebExchangeContextFilter
is present in the filter chain.- Parameters:
context
- the context to get the exchange from- Returns:
- an
Optional
with the exchange if found
-
getExchange(ContextView)
which accepts aContextView
instead ofContext
, reflecting the fact that theContextView
is needed only for reading.