I would like to know how to create a RestAdapter that can switch between two endpoints. Currently in my app, the RestAdapter is created in the Application class(singleton). I am looking for a way to have different endpoints without actually creating multiple RestAdapter.
Retrofit 1 calls Endpoint for each request (no cache), to you just need to extend Retrofit.Endpoint with some setter and pass this Endpoint when your creating the RestAdapter :
Endpoint mDynamicEndpoint = new DynamicEndpoint("http://firstdomain.fr");
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(mDynamicEndpoint)
.build();
mDynamicEndpoint.setBaseUrl("http://yourdomain.com");
Possible duplicate : Dynamic Paths in Retrofit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With