diff --git a/app/src/main/java/com/msg/gcms/data/remote/dto/auth/request/RefreshRequest.kt b/app/src/main/java/com/msg/gcms/data/remote/dto/auth/request/RefreshRequest.kt index 66793076..45a799c8 100644 --- a/app/src/main/java/com/msg/gcms/data/remote/dto/auth/request/RefreshRequest.kt +++ b/app/src/main/java/com/msg/gcms/data/remote/dto/auth/request/RefreshRequest.kt @@ -2,12 +2,17 @@ package com.msg.gcms.data.remote.dto.auth.request import com.google.gson.annotations.SerializedName import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody +import org.json.JSONObject data class RefreshRequest( @SerializedName("token") val token: String ) -fun RefreshRequest.toRequestBody() = - this.toString().toRequestBody("application/json".toMediaTypeOrNull()) \ No newline at end of file +fun RefreshRequest.toRequestBody(): RequestBody { + return JSONObject().apply { + put("token", this@toRequestBody.token) + }.toString().toRequestBody("application/json".toMediaTypeOrNull()) +} \ No newline at end of file diff --git a/app/src/main/java/com/msg/gcms/data/remote/network/LoginInterceptor.kt b/app/src/main/java/com/msg/gcms/data/remote/network/LoginInterceptor.kt index 85f89852..811fc889 100644 --- a/app/src/main/java/com/msg/gcms/data/remote/network/LoginInterceptor.kt +++ b/app/src/main/java/com/msg/gcms/data/remote/network/LoginInterceptor.kt @@ -24,12 +24,8 @@ class LoginInterceptor @Inject constructor( val request = chain.request() val path = request.url.encodedPath val method = request.method - val ignorePath = listOf( - "/auth" - ) - val ignoreMethod = listOf( - "POST" - ) + val ignorePath = listOf("/auth") + val ignoreMethod = listOf("POST") ignorePath.forEachIndexed { index, s -> if (s == path && ignoreMethod[index] == method) { diff --git a/app/src/main/java/com/msg/gcms/di/module/NetworkModule.kt b/app/src/main/java/com/msg/gcms/di/module/NetworkModule.kt index a6df4f37..9eb4e105 100644 --- a/app/src/main/java/com/msg/gcms/di/module/NetworkModule.kt +++ b/app/src/main/java/com/msg/gcms/di/module/NetworkModule.kt @@ -1,5 +1,6 @@ package com.msg.gcms.di.module +import android.util.Log import com.msg.gcms.BuildConfig import com.msg.gcms.data.remote.network.api.ClubAPI import com.msg.gcms.data.remote.network.api.AuthAPI @@ -13,6 +14,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.util.concurrent.TimeUnit @@ -22,9 +24,16 @@ import javax.inject.Singleton @InstallIn(SingletonComponent::class) object NetworkModule { + @Provides + fun provideHttpLoggingInterceptor(): HttpLoggingInterceptor { + return HttpLoggingInterceptor { message -> Log.v("HTTP", message) } + .setLevel(HttpLoggingInterceptor.Level.BODY) + } + @Provides @Singleton fun provideOkhttpClient( + httpLoggingInterceptor: HttpLoggingInterceptor, loginInterceptor: LoginInterceptor ): OkHttpClient { return OkHttpClient.Builder() @@ -35,6 +44,7 @@ object NetworkModule { // 읽기 타임 아웃의 반대 방향. 얼마나 빨리 서버에 바이트를 보낼 수 있는지 확인 .writeTimeout(30, TimeUnit.SECONDS) .addInterceptor(loginInterceptor) + .addInterceptor(httpLoggingInterceptor) .build() }