Spring Coud OpenFeign動態設置請求頭Header


這種方案目前不生效(版本: feign-core-10.4.0.jar),雖然注解時Feign包下的,但是不生效,可能是哪里沒配置對。

@FeignClient(url = "https://xxx.com", name = "sensetime")
public interface SensetimeFeign {
  @Headers({"Authorization: {Authorization}"})
  @PostMapping(path = "/xxx", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
  String silentImageVerification(@Param("Authorization") String signature);
}

 

使用SpringBoot web注解(生效)

@FeignClient(url = "https://xxx.com", name = "sensetime")
public interface SensetimeFeign {
  @PostMapping(path = "/xxx", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
  String silentImageVerification(@RequestHeader("Authorization") String signature);
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM