我需要爲每個由Retrofit 2.0.0-beta2庫發出的請求添加一個查詢參數。我發現this solution用於改造1.9,但如何添加在最新的庫版本RequestInterceptor
?有沒有辦法使用Retrofit 2爲每個請求添加查詢參數?
我的界面:
@GET("user/{id}")
Call<User> getUser(@Path("id")long id);
@GET("users/")
Call<List<User>> getUser();
客戶:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(CLIENT) // custom OkHTTP Client
.build();
service = retrofit.create(userService.class);
如果你成功地添加查詢參數的攔截器,你能在你的問題或你自己的問題的響應添加代碼? –