Преглед на файлове

Add Ordered support for Spring Cloud Gateway adapter

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao cdfive преди 5 години
родител
ревизия
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;
}
}

Loading…
Отказ
Запис