mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
1.13.4
This commit is contained in:
@@ -181,6 +181,8 @@ public class ApiConfig {
|
||||
*/
|
||||
private int storeErrorCapacity = 20;
|
||||
|
||||
private boolean useGateway;
|
||||
|
||||
public void addAppSecret(Map<String, String> appSecretPair) {
|
||||
for (Map.Entry<String, String> entry : appSecretPair.entrySet()) {
|
||||
this.isvManager.update(new IsvDefinition(entry.getKey(), entry.getValue()));
|
||||
|
@@ -94,7 +94,7 @@ public class ConfigLimitDto {
|
||||
*/
|
||||
public RateLimiter fetchRateLimiter() {
|
||||
if (rateLimiter == null) {
|
||||
synchronized (this.id) {
|
||||
synchronized (this) {
|
||||
if (rateLimiter == null) {
|
||||
rateLimiter = RateLimiter.create(tokenBucketCount);
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ public class RouteConfig {
|
||||
/**
|
||||
* 状态,0:待审核,1:启用,2:禁用。默认启用
|
||||
*/
|
||||
private Byte status = STATUS_ENABLE;
|
||||
private Byte status;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.gitee.sop.gatewaycommon.gateway.configuration;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.GatewayModifyResponseGatewayFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.LoadBalancerClientExtFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.ValidateFilter;
|
||||
@@ -30,10 +31,8 @@ import java.util.List;
|
||||
*/
|
||||
public class BaseGatewayConfiguration extends AbstractConfiguration {
|
||||
|
||||
public static boolean USE_GATEWAY;
|
||||
|
||||
public BaseGatewayConfiguration() {
|
||||
USE_GATEWAY = true;
|
||||
ApiConfig.getInstance().setUseGateway(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.gatewaycommon.manager;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.RouteConfig;
|
||||
import com.gitee.sop.gatewaycommon.bean.RouteStatus;
|
||||
import com.gitee.sop.gatewaycommon.util.MyBeanUtil;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -15,10 +16,11 @@ public class DefaultRouteConfigManager implements RouteConfigManager {
|
||||
*/
|
||||
protected static Map<String, RouteConfig> routeConfigMap = new ConcurrentHashMap<>(64);
|
||||
|
||||
private static RouteConfig DEFAULT_CONFIG;
|
||||
private static final RouteConfig DEFAULT_ROUTE_CONFIG;
|
||||
|
||||
public DefaultRouteConfigManager() {
|
||||
DEFAULT_CONFIG = this.newRouteConfig();
|
||||
static {
|
||||
DEFAULT_ROUTE_CONFIG = new RouteConfig();
|
||||
DEFAULT_ROUTE_CONFIG.setStatus(RouteStatus.ENABLE.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +49,6 @@ public class DefaultRouteConfigManager implements RouteConfigManager {
|
||||
|
||||
@Override
|
||||
public RouteConfig get(String routeId) {
|
||||
return routeConfigMap.getOrDefault(routeId, DEFAULT_CONFIG);
|
||||
return routeConfigMap.getOrDefault(routeId, DEFAULT_ROUTE_CONFIG);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.gitee.sop.gatewaycommon.message;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
||||
import com.gitee.sop.gatewaycommon.exception.ApiException;
|
||||
import com.gitee.sop.gatewaycommon.gateway.configuration.BaseGatewayConfiguration;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ErrorMeta {
|
||||
}
|
||||
|
||||
protected Locale getLocale() {
|
||||
if (BaseGatewayConfiguration.USE_GATEWAY) {
|
||||
if (ApiConfig.getInstance().isUseGateway()) {
|
||||
return ZH_CN;
|
||||
}
|
||||
RequestContext currentContext = RequestContext.getCurrentContext();
|
||||
|
Reference in New Issue
Block a user