zoukankan      html  css  js  c++  java
  • SpringCloud feign调用 请求头扩展

    feign调用有时候会需要在请求头中传入特殊属性,feign提供了这个扩展接口

    public interface RequestInterceptor {
    
      /**
       * Called for every request. Add data using methods on the supplied {@link RequestTemplate}.
       */
      void apply(RequestTemplate template);
    }
    

    demo如下

    public void apply(RequestTemplate input) {
       input.header("X-Auth";, currentToken);
    }
    

    接口说明:

    Zero or more RequestInterceptors may be configured for purposes such as adding headers to
    all requests. No guarantees are give with regards to the order that interceptors are applied.

    RequestInterceptors 用于在request上添加header,有多个是不能保证顺序。

  • 相关阅读:
    三数之和
    167
    二分搜索树
    687
    索引堆
    二分查找 leetcode704
    leetcode 56合并区间 java
    leetcode 1046
    堆的数据结构java
    leetcode 493
  • 原文地址:https://www.cnblogs.com/mengjianzhou/p/12765653.html
Copyright © 2011-2022 走看看