Kaloyan Roussev
Kaloyan Roussev

Reputation: 14711

How to prepend to the url of the API root in Retrofit / Can I have two Rest Adapters?

This is how I set up my RetroFit client.

    RestAdapter.Builder builder = new RestAdapter.Builder();
    builder.setEndpoint(Server.API_ROOT);
    builder.setExecutors(Executors.newFixedThreadPool(5), new ScheduledThreadPoolExecutor(5));
    RestAdapter restAdapter = builder.build();
    REST_CLIENT = restAdapter.create(API.class);

However, some of the API endpoints I'm using are http://example.com/ and others are http://test.example.com/ so what should I do?

Actually, can I have 2 adapters for two different APIs?

Upvotes: 0

Views: 384

Answers (1)

arbrcr
arbrcr

Reputation: 815

You will have to implement Endpoint

Sample: https://medium.com/@kevintcoughlin/dynamic-endpoints-with-retrofit-a1f4229f4a8d

If you are using 2.0 beta+ , EndPoint is renamed to BaseUrl

Also, take a look at this for 2.0+ :

New: @Url parameter annotation allows passing a complete URL for an endpoint.

Upvotes: 3

Related Questions