Skip to content

Commit

Permalink
[REFACTOR/#17] 요청에 memberID 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonsuKang committed Jun 7, 2024
1 parent 31b9727 commit b117997
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/src/main/java/com/sopt/now/compose/MemberIdInterceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ object MemberIdInterceptor : Interceptor {
private set

override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
var request = chain.request()

// 요청에 MemberID 헤더 추가
memberId?.let {
request = request.newBuilder()
.addHeader("MemberID", it)
.build()
}

val response = chain.proceed(request)

// 응답 헤더에서 Location 값 추출해서 memberId에 저장 때리기
// 응답 헤더에서 Location 값 추출해서 memberId에 저장
response.header("Location")?.let {
memberId = it
}

return response
}
}
}

0 comments on commit b117997

Please sign in to comment.