mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
2.0
This commit is contained in:
@@ -3,6 +3,7 @@ package com.gitee.sop.gatewaycommon.gateway.configuration;
|
||||
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.EnvGrayFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.GatewayModifyResponseGatewayFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.LimitFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.LoadBalancerClientExtFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.ParameterFormatterFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.ValidateFilter;
|
||||
@@ -89,6 +90,16 @@ public class BaseGatewayConfiguration extends AbstractConfiguration {
|
||||
return new ValidateFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ParameterFormatterFilter parameterFormatterFilter() {
|
||||
return new ParameterFormatterFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
LimitFilter limitFilter() {
|
||||
return new LimitFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
LoadBalancerClientExtFilter loadBalancerClientExtFilter() {
|
||||
return new LoadBalancerClientExtFilter();
|
||||
@@ -106,10 +117,6 @@ public class BaseGatewayConfiguration extends AbstractConfiguration {
|
||||
return gatewayRouteRepository;
|
||||
}
|
||||
|
||||
@Bean
|
||||
ParameterFormatterFilter parameterFormatterFilter() {
|
||||
return new ParameterFormatterFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
EnvGrayFilter envGrayFilter() {
|
||||
|
@@ -41,7 +41,7 @@ public class LimitFilter implements GlobalFilter, Ordered {
|
||||
}
|
||||
// 单个限流功能未开启
|
||||
if (configLimitDto.getLimitStatus() == ConfigLimitDto.LIMIT_STATUS_CLOSE) {
|
||||
return null;
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
byte limitType = configLimitDto.getLimitType().byteValue();
|
||||
LimitManager limitManager = ApiConfig.getInstance().getLimitManager();
|
||||
@@ -82,12 +82,15 @@ public class LimitFilter implements GlobalFilter, Ordered {
|
||||
List<ConfigLimitDto> limitConfigList = new ArrayList<>();
|
||||
for (String limitKey : limitKeys) {
|
||||
ConfigLimitDto configLimitDto = limitConfigManager.get(limitKey);
|
||||
if (configLimitDto == null) {
|
||||
continue;
|
||||
}
|
||||
limitConfigList.add(configLimitDto);
|
||||
}
|
||||
if (limitConfigList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Collections.sort(limitConfigList, Comparator.comparing(ConfigLimitDto::getOrderIndex));
|
||||
limitConfigList.sort(Comparator.comparing(ConfigLimitDto::getOrderIndex));
|
||||
return limitConfigList.get(0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user