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);
}

 

posted @ 2020-04-19 21:45  Laeni  阅读(8384)  评论(0编辑  收藏  举报