提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.env.core.fegin; |
H |
2 |
|
|
3 |
import cn.hutool.core.util.StrUtil; |
|
4 |
import com.iailab.framework.env.core.context.EnvContextHolder; |
|
5 |
import com.iailab.framework.env.core.util.EnvUtils; |
|
6 |
import feign.RequestInterceptor; |
|
7 |
import feign.RequestTemplate; |
|
8 |
|
|
9 |
/** |
|
10 |
* 多环境的 {@link RequestInterceptor} 实现类:Feign 请求时,将 tag 设置到 header 中,继续透传给被调用的服务 |
|
11 |
* |
|
12 |
* @author iailab |
|
13 |
*/ |
|
14 |
public class EnvRequestInterceptor implements RequestInterceptor { |
|
15 |
|
|
16 |
@Override |
|
17 |
public void apply(RequestTemplate requestTemplate) { |
|
18 |
String tag = EnvContextHolder.getTag(); |
|
19 |
if (StrUtil.isNotEmpty(tag)) { |
|
20 |
EnvUtils.setTag(requestTemplate, tag); |
|
21 |
} |
|
22 |
} |
|
23 |
|
|
24 |
} |