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
FieldsModifier and TypeFieldDescriptionstatic final StringAttribute name under which the exchange is saved in the context. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>filter(ServerWebExchange exchange, WebFilterChain chain) Process the Web request and (optionally) delegate to the nextWebFilterthrough the givenWebFilterChain.static Optional<ServerWebExchange>getExchange(reactor.util.context.ContextView contextView) Access theServerWebExchangefrom a ReactorContextView, if available, which is generally the case whenServerWebExchangeContextFilteris 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:WebFilterProcess the Web request and (optionally) delegate to the nextWebFilterthrough the givenWebFilterChain. -
getExchange
Access theServerWebExchangefrom a ReactorContextView, if available, which is generally the case whenServerWebExchangeContextFilteris present in the filter chain.- Parameters:
contextView- the contextView to get the exchange from- Returns:
- an
Optionalwith the exchange if found - Since:
- 6.0.6
-