package com.tofly.latte_core.net.interceptor;

import com.tofly.latte_core.utils.LattePreference;
import com.tofly.latte_core.utils.LogUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * @ClassName: CommonRequestInterceptor
 * @Description: 通用拦截器 ， 请求通用拦截器
 * @Author: Rivan
 * @CreateDate: 2020/12/28 18:12
 * @UpdateDate: 2020/12/28 18:12
 */
public class CommonRequestInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request.Builder builder = chain.request().newBuilder();
        builder.addHeader("os", "android");
//        builder.addHeader("appVersion", Latte.getConfiguration(ConfigKeys.INTERCEPTOR.name()));
        builder.addHeader("Source", "source");
        builder.addHeader("Authorization", "bearer " + LattePreference.getString("token"));

        LogUtils.e("token","bearer " + LattePreference.getString("token"));
        return chain.proceed(builder.build());
    }
}
