Retrofit: How can i "hot" change baseurl ?

Created on 1 Feb 2016  路  5Comments  路  Source: square/retrofit

For example the first baseurl is "http://aa.aa.com/", Second baseurl is "http://bb.bb.com/", how can i use singleton retrofit to "hot" change base url.

Most helpful comment

This has been my answer until 2.0.0. Why is BaseUrl removed?
Using @Url squashes all the path and query parameters into one, which makes it really inconvenient.

All 5 comments

I have the same problem. Hope a request level baseurl api.

The base url can change over time by implementing BaseUrl and returning different values (such as in a round robin or based on data from response headers). You can also specify a full host name in your HTTP annotation or use the @Url annotation on a parameter to allow specifying a full host name dynamically.

This has been my answer until 2.0.0. Why is BaseUrl removed?
Using @Url squashes all the path and query parameters into one, which makes it really inconvenient.

@jianghaolu See #1652

Was this page helpful?
0 / 5 - 0 ratings