在 Retrofit 2
中是否有可能将 Call
URL 与 String
进行比较?
例如我们可以采用这个baseUrl
:
https://www.google.com
而这个调用
:
public interface ExampleService {
@GET("dummy/{examplePartialUrl}/")
Call<JsonObject> exampleList(@Path("examplePartialUrl") String examplePartialUrl;
}
有了这个请求:
Call<JsonObject> mCall = dummyService.exampleList("partialDummy")
有没有办法在获得调用响应之前获取 https://www.google.com/dummy/partialDummy
或 dummy/partialDummy
?
最佳答案
假设您将 OkHttp 与 Retrofit 一起使用,您可以执行以下操作:
dummyService.exampleList("partialDummy").request().url().toString()
根据 OkHttp 文档应该打印:
https://www.google.com/dummy/partialDummy
关于android - Retrofit 2 检查调用 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36532273/