Class ServerWebExchangeContextFilter
- java.lang.Object
- org.springframework.web.filter.reactive.ServerWebExchangeContextFilter
- All Implemented Interfaces:
WebFilter
public class ServerWebExchangeContextFilter extends Object implements WebFilter
Inserts an attribute in the ReactorContext
that makes the currentServerWebExchange
available under the attribute nameEXCHANGE_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
Fields Modifier and Type Field Description static String
EXCHANGE_CONTEXT_ATTRIBUTE
Attribute name under which the exchange is saved in the context.
Constructor Summary
Constructors Constructor Description ServerWebExchangeContextFilter()
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.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)
Access theServerWebExchange
from the Reactor Context, if available, which is ifServerWebExchangeContextFilter
is configured for use and the give context was obtained from a request processing chain.
Field Detail
EXCHANGE_CONTEXT_ATTRIBUTE
public static final String EXCHANGE_CONTEXT_ATTRIBUTE
Attribute name under which the exchange is saved in the context.
Constructor Detail
ServerWebExchangeContextFilter
public ServerWebExchangeContextFilter()
Method Detail
filter
public reactor.core.publisher.Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain)
Description copied from interface:WebFilter
Process the Web request and (optionally) delegate to the nextWebFilter
through the givenWebFilterChain
.
get
public static Optional<ServerWebExchange> get(reactor.util.context.Context context)
Access theServerWebExchange
from the Reactor Context, if available, which is ifServerWebExchangeContextFilter
is 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