Merge pull request #1350 from Gsealy/1341-order-doc

remove support Order annotation in document.  Fixes gh-1341
This commit is contained in:
Ryan Baxter
2019-10-15 09:57:14 -05:00
committed by GitHub

View File

@@ -1205,44 +1205,30 @@ The `GlobalFilter` interface has the same signature as `GatewayFilter`. These ar
=== Combined Global Filter and GatewayFilter Ordering
When a request comes in (and matches a Route) the Filtering Web Handler will add all instances of `GlobalFilter` and all route specific instances of `GatewayFilter` to a filter chain. This combined filter chain is sorted by the `org.springframework.core.Ordered` interface, which can be set by implementing the `getOrder()` method or by using the `@Order` annotation.
When a request comes in (and matches a Route) the Filtering Web Handler will add all instances of `GlobalFilter` and all route specific instances of `GatewayFilter` to a filter chain. This combined filter chain is sorted by the `org.springframework.core.Ordered` interface, which can be set by implementing the `getOrder()` method.
As Spring Cloud Gateway distinguishes between "pre" and "post" phases for filter logic execution (see: How It Works), the filter with the highest precedence will be the first in the "pre"-phase and the last in the "post"-phase.
As Spring Cloud Gateway distinguishes between "pre" and "post" phases for filter logic execution (see: <<gateway-how-it-works, How it Works>>), the filter with the highest precedence will be the first in the "pre"-phase and the last in the "post"-phase.
.ExampleConfiguration.java
[source,java]
----
@Bean
@Order(-1)
public GlobalFilter a() {
return (exchange, chain) -> {
log.info("first pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
log.info("third post filter");
}));
};
public GlobalFilter customFilter() {
return CustomGlobalFilter();
}
@Bean
@Order(0)
public GlobalFilter b() {
return (exchange, chain) -> {
log.info("second pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
log.info("second post filter");
}));
};
}
public class CustomGlobalFilter implements GlobalFilter, Ordered {
@Bean
@Order(1)
public GlobalFilter c() {
return (exchange, chain) -> {
log.info("third pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
log.info("first post filter");
}));
};
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
log.info("custom global filter");
return chain.filter(exchange);
}
@Override
public int getOrder() {
return -1;
}
}
----