18034727885
2026-05-14 dad2ded3e9e9d2edf55c7ce10e791588b526961f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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())
    }
 
}