question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass base url or host as a param

See original GitHub issue

I have a use case where I have a list of hosts, I need to loop over those hosts and make the same api call for each of them. I don’t want a hardcoded base url as that would mean creating a new feign client for each api call.

I would like to do something like:

public class FeignBaseUrlParamTest {

    @Test
    public void testIt() {
        MyClient client = Feign.builder().target(Target.EmptyTarget.create(MyClient.class));
        client.internalService("http://localhost:8080");
    }
}

interface MyClient {
    @RequestLine("GET {baseUrl}/internal-service")
    String internalService(@Param("baseUrl") String host);
}

However this encodes the base url part and the following exception occurs:

feign.RetryableException: no protocol: http%3A//localhost%3A8080/internal-service executing GET http%3A//localhost%3A8080/internal-service

I tried to create a Target implementation which gets the url out and decodes everything before the path. However it is not possible as you can only perform additions to the url from that context.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
codefromthecryptcommented, Feb 29, 2016

I think you want to just add an unannotated URI param

interface MyClient { @RequestLine(“GET /internal-service”) String internalService(URI baseUrl); }

2reactions
tomradcliffecommented, Apr 22, 2016

That works perfectly. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set base url and query parameters for WebClient?
Is it possible to set scheme, host, port in a method together? I know that webClient.get().uri("http://a.com:8080/path1?param1=v1").retrieve() ...
Read more >
Base URL - Testim overview
Base URL · Running remotely · Base URL Parameter · Overriding base URL and navigation hosts · Rerun with the same parameters.
Read more >
API Host and Base Path - Swagger
REST APIs have a base URL to which the endpoint paths are appended. The base URL is defined by schemes , host and...
Read more >
Adding Base URL to REST Service
A base URL path includes the hostname of the server where the REST Service ... parameter is an expression that represents a value...
Read more >
What is the composition of the URL? in REST API - Numpy Ninja
The base URL is the internet host name for the REST API. The resource path is the address to the API resource. Query...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found