feign加入hystrix熔断器之后转发不了token等header信息,我把熔断注释了,就可以转发。但这不是我想要的答案。
转发代码如下:
@Configuration
public class FeignConfig implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
String token = null;
String platform = null;
if(attributes != null) {
HttpServletRequest request = attributes.getRequest();
token = request.getHeader("token");
platform = request.getHeader("p_platform");
}
//添加token
requestTemplate.header("token", token);
requestTemplate.header("p_platform", platform);
}
}上面的ServletRequestAttributes attributes
在熔断中取不到,可能是因