package com.example.smart.reqeust.interceptor
|
|
import android.text.TextUtils
|
import com.example.basecore.util.SPUtils
|
import com.example.smart.util.StatusProvider
|
import okhttp3.Interceptor
|
import okhttp3.Response
|
|
|
|
class HeaderInterceptor : Interceptor{
|
|
|
|
companion object {
|
|
|
const val authorization = "Authorization"
|
|
const val auth_tk = "auth-tk"
|
}
|
|
override fun intercept(chain: Interceptor.Chain): Response {
|
|
val builder = chain.request().newBuilder()
|
val token = StatusProvider.getToken()
|
if (!TextUtils.isEmpty(token)) {
|
builder.addHeader(authorization, "Bearer $token")
|
// builder.addHeader(auth_tk, token)
|
}
|
|
|
return chain.proceed(builder.build())
|
}
|
|
}
|