Is your feature request related to a problem? Please describe.

My team currently is a heavy user of Feign clients. We do not use Spring Cloud features like load balancers or service discovery.

We have an internal gateway where our applications make requests between each other.

Over the time, we created few configurations to allow editing the URL parameter of the Feign client, but now the SpEL used in the url is gigantic and must be the same for all Feign clients. Would be nice to be able to provide a custom configuration for everyone to use in their Feign clients that will automatically generate the URL based on our needs.

Example:

@FeignClient(
    contextId = "UserApi",
    name = "upms",
    url = "${foo.microservice.upms.url:${foo.gateway.internal.host}/upms/${foo.microservice.upms.version:${spring.profiles.active}}}")
public interface UserApi {
}

@FeignClient(
    contextId = "RoleApi",
    name = "upms",
    url = "${foo.microservice.upms.url:${foo.gateway.internal.host}/upms/${foo.microservice.upms.version:${spring.profiles.active}}}")
public interface RoleApi {
}

In summary:

Our applications are available in a internal gateway. Example: https://my-gateway-host/<app-name>/<app-version>.

With this URL: - Devs can set foo.microservice.user.url to change the entire url. - Devs can change only the foo.microservice.user.version to change the <app-version> of the gateway path to use another instance of the same application running with a different code (or configuration), which defaults to the default version (for example dev, staging, being set as profiles right now). - Devs can change the foo.gateway.internal.host to change the gateway they will use.

I want to have a custom configuration that will configure the URL using dynamic properties where devs can re-use the same configuration and remove this giganic string from their feign clients.

In the reality the URL is even bigger because we set a custom default version and also a custom default gateway host to avoid setting them in every single integration test, because after 4.x values are being resolved eagerly and started to fail tests when properties could not be resolved in their fallbacks, even without using the feign client in the test.

Example of how would work:

@FeignClient(
    contextId = "UserApi",
    name = "upms",
    urlProvider = MyCustomUrlProvider.class)
public interface UserApi {
}

@FeignClient(
    contextId = "RoleApi",
    name = "upms",
    urlProvider = MyCustomUrlProvider.class)
public interface RoleApi {
}

public class MyCustomProvider extends CustomUrlProvider {

    // This is a custom class I have to allow easy access to configuration properties. Should  be able to inject using constructor, of course, just using autowired for clarity
    @Autowired
    public ConfigurationProvider configurationProvider;

    public String provideUrl(FeignClient client) {
       var defaultValue = "foo.microservice."+client.name()+".url";
       if (configurationProvider.has(defaultValue)) {
        return configurationProvider.get(defaultValue);
       }

       var versionValue = "foo.microservice."+client.name()+".version"
       String version = configurationProvider.get(versionValue);

       if (version == null) {
          version = configurationProvider.get("spring.profiles.active");
       }

       return configurationProvider.get("foo.gateway.internal.host") + "/" + client.name() + "/" + version
    }
}

Describe the solution you'd like

A configuration should be able to override the URL of a specific feign client.

Describe alternatives you've considered

The alternative is the one we are using right now.

Comment From: OlgaMaciaszek

Hello @lucasoares, thanks for reporting the issue. As documented, Spring Cloud OpenFeign is a maintenance-only projects. We do fix security issues and bugs, but any active development in the area of declarative clients is done only for Spring Interface Clients that we suggest as replacement. Given that this is not a bug or security issue and that workarounds are available, we will not be adding this to the backlog.

Comment From: lucasoares

Hello @lucasoares, thanks for reporting the issue. As documented, Spring Cloud OpenFeign is a maintenance-only projects. We do fix security issues and bugs, but any active development in the area of declarative clients is done only for Spring Interface Clients that we suggest as replacement. Given that this is not a bug or security issue and that workarounds are available, we will not be adding this to the backlog.

Sad to hear that.