Retrofit的Url組合規(guī)則
| BaseUrl | 和URL有關(guān)的注解中提供的值 | 最后結(jié)果 |
|---|---|---|
| http://localhost:4567/path/to/other/ | /post | http://localhost:4567/post |
| http://localhost:4567/path/to/other/ | post | http://localhost:4567/path/to/other/post |
| http://localhost:4567/path/to/other/ | https://github.com/ikidou | https://github.com/ikidou |
從上面不能難看出以下規(guī)則:
- 如果你在注解中提供的url是完整的url,則url將作為請求的url。
- 如果你在注解中提供的url是不完整的url,且不以 / 開頭,則請求的url為baseUrl+注解中提供的值
- 如果你在注解中提供的url是不完整的url,且以 / 開頭,則請求的url為baseUrl的主機部分+注解中提供的值