CLOVIS
CoroutineContext
Aleksei Tirman [JB]
class MyElement : CoroutineContext.Element { override val key: CoroutineContext.Key<*> get() = MyElement companion object : CoroutineContext.Key<MyElement> } fun main() { embeddedServer(Netty, host = "0.0.0.0", port = 12345) { sendPipeline.intercept(ApplicationSendPipeline.Before) { withContext(coroutineContext + MyElement()) { proceed() } } sendPipeline.intercept(ApplicationSendPipeline.Transform) { println(coroutineContext[MyElement]) } routing { get("/") { call.respondText { "OK" } } } }.start(wait = true) }
ApplicationSendPipeline.Before
call.respondText
ApplicationCallPipeline.Plugins
A modern programming language that makes developers happier.