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
-