package com.fuban.user.network;
|
|
import org.jetbrains.annotations.NotNull;
|
import java.io.IOException;
|
import cn.sinata.xldutils.utils.SPUtils;
|
import okhttp3.Interceptor;
|
import okhttp3.Request;
|
import okhttp3.Response;
|
public class InterUtil {
|
public static Interceptor get(){
|
Interceptor interceptor = new Interceptor() {
|
@NotNull
|
@Override
|
public Response intercept(@NotNull Chain chain) throws IOException {
|
String token = SPUtils.Companion.instance().getString("token","");
|
Request request = token.isEmpty()? chain.request():chain.request().newBuilder().addHeader("Authorization", "Bearer "+token).build();
|
return chain.proceed(request);
|
}
|
};
|
return interceptor;
|
}
|
|
}
|