mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
修复cloud gateway调用异常
This commit is contained in:
@@ -30,6 +30,11 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class BaseGatewayConfiguration extends AbstractConfiguration {
|
public class BaseGatewayConfiguration extends AbstractConfiguration {
|
||||||
|
|
||||||
|
public static boolean USE_GATEWAY;
|
||||||
|
static {
|
||||||
|
USE_GATEWAY = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义异常处理[@@]注册Bean时依赖的Bean,会从容器中直接获取,所以直接注入即可
|
* 自定义异常处理[@@]注册Bean时依赖的Bean,会从容器中直接获取,所以直接注入即可
|
||||||
*
|
*
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
package com.gitee.sop.gatewaycommon.manager;
|
package com.gitee.sop.gatewaycommon.manager;
|
||||||
|
|
||||||
|
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
||||||
import com.gitee.sop.gatewaycommon.bean.ApiContext;
|
import com.gitee.sop.gatewaycommon.bean.ApiContext;
|
||||||
import com.gitee.sop.gatewaycommon.bean.BeanInitializer;
|
import com.gitee.sop.gatewaycommon.bean.BeanInitializer;
|
||||||
import com.gitee.sop.gatewaycommon.message.ErrorFactory;
|
import com.gitee.sop.gatewaycommon.message.ErrorFactory;
|
||||||
|
import com.gitee.sop.gatewaycommon.secret.IsvManager;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -32,6 +34,21 @@ public class AbstractConfiguration implements ApplicationContextAware {
|
|||||||
applicationContext = ctx;
|
applicationContext = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
IsvManager isvManager() {
|
||||||
|
return ApiConfig.getInstance().getIsvManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
IsvRoutePermissionManager isvRoutePermissionManager() {
|
||||||
|
return ApiConfig.getInstance().getIsvRoutePermissionManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
RouteConfigManager routeConfigManager() {
|
||||||
|
return ApiConfig.getInstance().getRouteConfigManager();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跨域过滤器
|
* 跨域过滤器
|
||||||
*
|
*
|
||||||
@@ -39,9 +56,7 @@ public class AbstractConfiguration implements ApplicationContextAware {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public CorsFilter corsFilter() {
|
public CorsFilter corsFilter() {
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
return createCorsFilter();
|
||||||
source.registerCorsConfiguration("/**", corsConfiguration());
|
|
||||||
return new CorsFilter(source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CorsFilter createCorsFilter() {
|
protected CorsFilter createCorsFilter() {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package com.gitee.sop.gatewaycommon.message;
|
package com.gitee.sop.gatewaycommon.message;
|
||||||
|
|
||||||
import com.gitee.sop.gatewaycommon.exception.ApiException;
|
import com.gitee.sop.gatewaycommon.exception.ApiException;
|
||||||
|
import com.gitee.sop.gatewaycommon.gateway.configuration.BaseGatewayConfiguration;
|
||||||
import com.netflix.zuul.context.RequestContext;
|
import com.netflix.zuul.context.RequestContext;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -54,6 +55,9 @@ public class ErrorMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Locale getLocale() {
|
protected Locale getLocale() {
|
||||||
|
if (BaseGatewayConfiguration.USE_GATEWAY) {
|
||||||
|
return ZH_CN;
|
||||||
|
}
|
||||||
RequestContext currentContext = RequestContext.getCurrentContext();
|
RequestContext currentContext = RequestContext.getCurrentContext();
|
||||||
if (currentContext == null) {
|
if (currentContext == null) {
|
||||||
return ZH_CN;
|
return ZH_CN;
|
||||||
|
@@ -1,12 +1,8 @@
|
|||||||
package com.gitee.sop.gatewaycommon.zuul.configuration;
|
package com.gitee.sop.gatewaycommon.zuul.configuration;
|
||||||
|
|
||||||
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
|
||||||
import com.gitee.sop.gatewaycommon.bean.ApiContext;
|
import com.gitee.sop.gatewaycommon.bean.ApiContext;
|
||||||
import com.gitee.sop.gatewaycommon.manager.AbstractConfiguration;
|
import com.gitee.sop.gatewaycommon.manager.AbstractConfiguration;
|
||||||
import com.gitee.sop.gatewaycommon.manager.IsvRoutePermissionManager;
|
|
||||||
import com.gitee.sop.gatewaycommon.manager.RouteConfigManager;
|
|
||||||
import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext;
|
import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext;
|
||||||
import com.gitee.sop.gatewaycommon.secret.IsvManager;
|
|
||||||
import com.gitee.sop.gatewaycommon.zuul.filter.ErrorFilter;
|
import com.gitee.sop.gatewaycommon.zuul.filter.ErrorFilter;
|
||||||
import com.gitee.sop.gatewaycommon.zuul.filter.PostResultFilter;
|
import com.gitee.sop.gatewaycommon.zuul.filter.PostResultFilter;
|
||||||
import com.gitee.sop.gatewaycommon.zuul.filter.PreLimitFilter;
|
import com.gitee.sop.gatewaycommon.zuul.filter.PreLimitFilter;
|
||||||
@@ -120,18 +116,4 @@ public class BaseZuulConfiguration extends AbstractConfiguration {
|
|||||||
return ApiContext.getApiConfig().getZuulErrorController();
|
return ApiContext.getApiConfig().getZuulErrorController();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
IsvManager isvManager() {
|
|
||||||
return ApiConfig.getInstance().getIsvManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
IsvRoutePermissionManager isvRoutePermissionManager() {
|
|
||||||
return ApiConfig.getInstance().getIsvRoutePermissionManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
RouteConfigManager routeConfigManager() {
|
|
||||||
return ApiConfig.getInstance().getRouteConfigManager();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user