package cn.muchinfo.rma.netManage.base.interceptor

import okhttp3.Interceptor
import okhttp3.Response

/**
 *   @auther : lbl
 *   time   : 2021/1/02
 */
class BaseInterceptor(private val headers: Map<String, String>?) : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        return chain.proceed(chain.request().newBuilder().run {
            if (!headers.isNullOrEmpty()) {
                for (headMap in headers) {
                    addHeader(headMap.key, headMap.value).build()
                }
            }
            build()
        })
    }
}