File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
src/main/kotlin/org/gitanimals Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 11package org.gitanimals.guild.infra
22
3+ import org.gitanimals.core.filter.MDCFilter.Companion.TRACE_ID
34import org.gitanimals.guild.app.IdentityApi
45import org.gitanimals.guild.app.RenderApi
6+ import org.slf4j.MDC
57import org.springframework.context.annotation.Bean
68import org.springframework.context.annotation.Configuration
79import org.springframework.context.annotation.Profile
@@ -17,6 +19,9 @@ class HttpClientConfigurer {
1719 fun identityApiHttpClient (): IdentityApi {
1820 val restClient = RestClient
1921 .builder()
22+ .defaultHeaders {
23+ it.add(TRACE_ID , MDC .get(TRACE_ID ))
24+ }
2025 .defaultStatusHandler(httpClientErrorHandler())
2126 .baseUrl(" https://api.gitanimals.org" )
2227 .build()
@@ -32,6 +37,9 @@ class HttpClientConfigurer {
3237 fun renderApiHttpClient (): RenderApi {
3338 val restClient = RestClient
3439 .builder()
40+ .defaultHeaders {
41+ it.add(TRACE_ID , MDC .get(TRACE_ID ))
42+ }
3543 .defaultStatusHandler(httpClientErrorHandler())
3644 .baseUrl(" https://render.gitanimals.org" )
3745 .build()
Original file line number Diff line number Diff line change 11package org.gitanimals.render.infra
22
33import org.gitanimals.core.AUTHORIZATION_EXCEPTION
4+ import org.gitanimals.core.filter.MDCFilter.Companion.TRACE_ID
45import org.gitanimals.render.app.IdentityApi
6+ import org.slf4j.MDC
57import org.springframework.http.HttpHeaders
68import org.springframework.stereotype.Component
79import org.springframework.web.client.RestClient
@@ -15,6 +17,7 @@ class RestIdentityApi : IdentityApi {
1517 return restClient.get()
1618 .uri(" /users" )
1719 .header(HttpHeaders .AUTHORIZATION , token)
20+ .header(TRACE_ID , MDC .get(TRACE_ID ))
1821 .exchange { _, response ->
1922 runCatching {
2023 response.bodyTo(IdentityApi .UserResponse ::class .java)
You can’t perform that action at this time.
0 commit comments