package com.sd.cavphmi.net


import com.sd.cavphmi.utils.MyContants
import okhttp3.Interceptor
import okhttp3.Response
import javax.inject.Inject

/**
 * 公共参数拦截处理器 http://blog.csdn.net/spinchao/article/details/52932145
 */
class HeadParamsInterceptor @Inject constructor() : Interceptor {


    override fun intercept(chain: Interceptor.Chain): Response {
//        LogUtil.d("----------token=" + MyPres.token)
        var original = chain.request()
//        var path = original.url.encodedPath.substringAfterLast("/")
        var request = original.newBuilder()
        if (MyContants.HTTP_TOKEN.isNotEmpty()) {
            request.header("token", MyContants.HTTP_TOKEN)
            request.header("Authorization",  MyContants.HTTP_TOKEN)
        }
//        request.header("Referer", "${MyContants.HOST}/itdts-portal-v5/intelligence-parking")
        request.header("Referer", "https://itg-yz.cu-sc.com:13443/itdts-portal-v5/intelligence-parking")
        return chain.proceed(request.build())
    }

}