我目前正在学习安卓中的Retrofit:
这是我的当前代码:
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
Request newRequest = chain.request().newBuilder()
.addHeader("Authorization", "Bearer " + Globals.BEARER_TOKEN)
.build();
return chain.proceed(newRequest);
}
}).build();
我该如何将我的HttpLoggingInterceptor添加到客户端,并同时将我的标头添加到客户端?