spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Add support for placeholders to Feign spring-mvc annotations of headers field

Open ddf2008 opened this issue 4 years ago • 1 comments

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

ddf2008 avatar Jan 31 '20 06:01 ddf2008

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!

IlyasYOY avatar Feb 10 '20 20:02 IlyasYOY