cn.ishow.starter.rpc.basic.HeaderInterceptor Maven / Gradle / Ivy
package cn.ishow.starter.rpc.basic;
import cn.ishow.starter.common.context.App;
import cn.ishow.starter.common.util.spring.WebUtils;
import feign.RequestInterceptor;
import feign.RequestTemplate;
/**
* 特定请求头设置器
*
* @author bucheng
* @create 2022/6/20 21:17
* @description
*/
public class HeaderInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate template) {
template.header("X-Upstream-Service", App.getServiceName());
template.header("userId", WebUtils.getHeader("userId"));
}
}