Add OkHttpBuilder tests

This commit is contained in:
Kirill Kamakin
2021-11-13 19:03:13 +03:00
parent b6b11a9f49
commit 0ff9afa4c6
2 changed files with 43 additions and 1 deletions

View File

@@ -3,13 +3,15 @@ package gq.kirmanak.mealie.data.auth.impl
import okhttp3.Interceptor
import okhttp3.Response
const val AUTHORIZATION_HEADER = "Authorization"
class AuthOkHttpInterceptor(token: String) : Interceptor {
private val headerValue = "Bearer $token"
override fun intercept(chain: Interceptor.Chain): Response {
val newRequest = chain.request()
.newBuilder()
.addHeader("Authorization", headerValue)
.addHeader(AUTHORIZATION_HEADER, headerValue)
.build()
return chain.proceed(newRequest)
}