Add Ordered support for Spring Cloud Gateway adapter
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
fb31bb8d4d
commit
103fa307e5
|
|
@ -34,6 +34,7 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
import org.springframework.cloud.gateway.route.Route;
|
import org.springframework.cloud.gateway.route.Route;
|
||||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
|
@ -41,7 +42,17 @@ import reactor.core.publisher.Mono;
|
||||||
* @author Eric Zhao
|
* @author Eric Zhao
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
public class SentinelGatewayFilter implements GatewayFilter, GlobalFilter {
|
public class SentinelGatewayFilter implements GatewayFilter, GlobalFilter, Ordered {
|
||||||
|
|
||||||
|
private final int order;
|
||||||
|
|
||||||
|
public SentinelGatewayFilter() {
|
||||||
|
this(Ordered.HIGHEST_PRECEDENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SentinelGatewayFilter(int order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
private final GatewayParamParser<ServerWebExchange> paramParser = new GatewayParamParser<>(
|
private final GatewayParamParser<ServerWebExchange> paramParser = new GatewayParamParser<>(
|
||||||
new ServerWebExchangeItemParser());
|
new ServerWebExchangeItemParser());
|
||||||
|
|
@ -87,4 +98,9 @@ public class SentinelGatewayFilter implements GatewayFilter, GlobalFilter {
|
||||||
.map(WebExchangeApiMatcher::getApiName)
|
.map(WebExchangeApiMatcher::getApiName)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder() {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue