Просмотр исходного кода

Add Ordered support for Spring Cloud Gateway adapter

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao cdfive 5 лет назад
Родитель
Сommit
103fa307e5
1 измененных файлов: 17 добавлений и 1 удалений
  1. +17
    -1
      sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SentinelGatewayFilter.java

+ 17
- 1
sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SentinelGatewayFilter.java Просмотреть файл

@@ -34,6 +34,7 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.cloud.gateway.route.Route;
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@@ -41,7 +42,17 @@ import reactor.core.publisher.Mono;
* @author Eric Zhao
* @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<>(
new ServerWebExchangeItemParser());
@@ -87,4 +98,9 @@ public class SentinelGatewayFilter implements GatewayFilter, GlobalFilter {
.map(WebExchangeApiMatcher::getApiName)
.collect(Collectors.toSet());
}

@Override
public int getOrder() {
return order;
}
}

Загрузка…
Отмена
Сохранить