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

Allow for feign.client.config.specific-client.default-XXX config to override feign.client.config.default.default-XXX

Open pgehl opened this issue 3 years ago • 0 comments
trafficstars

Is your feature request related to a problem? Please describe. Our spring-cloud-openfeign clients have a default configuration in a starter. Only one showed for example.

feign.client.config.default.default-request-headers.accept=application/json

In some rare cases we implement specific clients that need different values. (for example purpose)

feign.client.config.specific-client.default-request-headers.accept=application/xml

Unfortunately FeignClientFactoryBean.addDefaultRequestHeaders() (version 3.1.2) lines 326 to 328 contain:

if (!headers.containsKey(key)) {
    requestTemplate.header(key, defaultRequestHeaders.get(key));
}

specific-client config always passes after default client config, therefore the accept header value is never application/xml.

Describe the solution you'd like It would be nice (and backward compatible) if there was a config property to allow for default config to be applied after specific ones if enabled. Something like:

feign.client.config.apply-default-after=true

with the default value being false.

Describe alternatives you've considered We are still trying to figure out a way to override.

Additional context spring-cloud-openfeign version 3.1.2

pgehl avatar May 12 '22 12:05 pgehl