Last active
November 25, 2018 07:57
-
-
Save adamw/437344352d9e47c545da08e1a4243680 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
object CorrelationId { | |
val CorrelationIdHeader = "X-Correlation-ID" | |
def setCorrelationIdMiddleware(service: HttpRoutes[Task]): HttpRoutes[Task] = | |
Kleisli { req: Request[Task] => | |
val cid = req.headers.get(CaseInsensitiveString(CorrelationIdHeader)) match { | |
case None => newCorrelationId() | |
case Some(cidHeader) => cidHeader.value | |
} | |
localCid.update(Some(cid)) | |
logger.info("Starting request") | |
service(req) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment