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 get(Context) 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>get(reactor.util.context.Context context) Access theServerWebExchangefrom the Reactor Context, if available, which is ifServerWebExchangeContextFilteris configured for use and the give context was obtained from a request processing 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. -
get
Access theServerWebExchangefrom the Reactor Context, if available, which is ifServerWebExchangeContextFilteris configured for use and the give context was obtained from a request processing chain.- Parameters:
context- the context in which to access the exchange- Returns:
- the exchange
-