Reputation: 2446
I'm writing a Spring Web Flux application. I have created two WebFilter Component:
AlphaFilter
class AlphaFilter implement WebFilter {
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
// ....
// Alpha Filter Configurations
return chain.filter(exchange);
}
}
AuthenticationFilter
class AuthenticationFilter implement WebFilter {
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
// ....
// Alpha Filter Configurations
return chain.filter(exchange);
}
}
I wanted to ensure that AuthenticationFilter
runs before AlphaFilter
. How to configure the filters so that AuthenticationFilter
runs before AlphaFilter
?
Upvotes: 1
Views: 5228
Reputation: 1181
Sagar,
Does this part of the documentation answer your question?
In the WebHandler API, you can use a WebFilter to apply interception-style logic before and after the rest of the processing chain of filters and the target WebHandler. When using the WebFlux Config, registering a WebFilter is as simple as declaring it as a Spring bean and (optionally) expressing precedence by using @Order on the bean declaration or by implementing Ordered.
Upvotes: 2