okhttp3 url轮询负载均衡拦截器
okhttp3添加拦截器
new OkHttpClient.Builder().addInterceptor(new PollInterceptor(urls)).build()
添加日志拦截器:
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(Level.BODY);
new OkHttpClient.Builder().addInterceptor(httpLoggingInterceptor).build()
自定义轮询负载均衡拦截器
话不多说直接上代码:
public class PollInterceptor implements Interceptor {
// url
pri
共有 0 条评论