spring-cloud-openfeign
spring-cloud-openfeign copied to clipboard
Add support for placeholders to Feign spring-mvc annotations of headers field
Hi, I saw there is an issue spring-cloud/spring-cloud-netflix#894 which add support for placeholders of value field. But other field such as "headers" still not support placeholder. Since sometimes we need set Authentication header, it is awesome if the value could be loaded from properties file.
@FeignClient("foo")
public interface FooClient{
@RequestMapping(value = "${my.special.placeholder}",
method = RequestMethod.GET,
headers = "${my.token}"
ResponseEntity getSomeData(s);
}
Hello there!
I think that this is the thing you're looking for!
Code snippet:
@RequestMapping(method = RequestMethod.GET, path = "/helloheadersplaceholders",
headers = "myPlaceholderHeader=${feignClient.myPlaceholderHeader}")
String getHelloHeadersPlaceholders();
I've opened the issue (#284) that looks similar to your problem, but is easier to be used, because it does not require any code to extend the functionality.
I hope this helps!