Starting with OkHttp v3 OkHttpClient is immutable and so is the interceptor's list.
Starting with Retrofit 2.0-beta3 it depends on OkHttp v3.
In my app I need to parse Google Analytics Campain refferer key, which has "a=1&b=2&c=3" format, and append it to sign up request URL.
With previous version of retrofit it was easy to do by adding
retrofit.client().interceptors().add(0, chain -> {
final Request httpRequest = chain.request();
return chain.proceed(httpRequest.newBuilder().url(httpRequest.httpUrl().toString() + "&" + request.getUtmParams()).build());
});
before executing call and
retrofit.client().interceptors().remove(0);
after call is proceed.
Can't figure out how to achieve the same behaviour with the new version. Please help.
UPD 1. The goal is to control request URL of single request. Appending string to the end is just an example. Using @QueryMap is an option, but it requires parsing parameter string which I try to avoid.
Interceptors didn't much changed. Parsing utm from url is easy with uri utils. - Nikola Despotoski