Browse Source

网关服务feign错误

yingp 7 years ago
parent
commit
a53d3d863d

+ 28 - 0
base-servers/gateway-server/src/main/java/com/usoftchina/saas/gateway/interceptor/ServiceFeignInterceptor.java

@@ -0,0 +1,28 @@
+package com.usoftchina.saas.gateway.interceptor;
+
+import com.usoftchina.saas.gateway.config.AuthConfig;
+import com.usoftchina.saas.context.BaseContextHolder;
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author yingp
+ * @date 2018/10/2
+ */
+public class ServiceFeignInterceptor implements RequestInterceptor {
+    @Autowired
+    private AuthConfig authConfig;
+
+    public ServiceFeignInterceptor() {
+    }
+
+    @Override
+    public void apply(RequestTemplate requestTemplate) {
+        requestTemplate.header(authConfig.getAuthHeader(), BaseContextHolder.getToken());
+    }
+
+    public void setAuthConfig(AuthConfig authConfig) {
+        this.authConfig = authConfig;
+    }
+}