|
|
@@ -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;
|
|
|
+ }
|
|
|
+}
|