Last active
February 22, 2019 18:42
-
-
Save segabond/18c33a1c4e5f25c400792c0cb8a2106f to your computer and use it in GitHub Desktop.
KTOR MDC correlation ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Application.myApp() { | |
install(CallLogging) { | |
mdc("correlationId") { call -> | |
call.request.header("X-Correlation-ID") ?: | |
} | |
} | |
} | |
fun configureHttpClient() = | |
HttpClient(Apache) { | |
defaultRequest { | |
MDC.get("correlationId")?.also { | |
header("X-Correlation-ID", it) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment