码迷,mamicode.com
首页 > 其他好文 > 详细

feign请求头copy

时间:2021-03-16 14:01:13      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:tor   app   component   void   inter   Servle   ext   values   feign   

@Component
public class SecuringRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
                .getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        Enumeration<String> headerNames = request.getHeaderNames();
        if (headerNames != null) {
            while (headerNames.hasMoreElements()) {
                String name = headerNames.nextElement();
                String values = request.getHeader(name);
                requestTemplate.header(name, values);
            }
        }
    }
}
RequestInterceptor 是feign包中的

feign请求头copy

标签:tor   app   component   void   inter   Servle   ext   values   feign   

原文地址:https://www.cnblogs.com/hanzhengjie/p/14536900.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!