heyhey, I am trying to create a Ktor server plugin...
# ktor
m
heyhey, I am trying to create a Ktor server plugin where I want to set a custom coroutine context (
withContext
), that should be used when handling requests. (I want to create an active span with opentelemetry-extension-kotlin that is tied to the coroutine context). Looking through the examples I can only see before and after hooks, but nothing like an around interceptor. Any ideas?
a
You can still use interceptors if you need.
m
Is there an existing plugin that does something similar? I am struggling to see how this can be done.
Copy code
pipeline.intercept(ApplicationCallPipeline.Call) {
  withContext(myContext){
   // how to proceed here?                
  }
}
Found it 😂
Copy code
pipeline.intercept(ApplicationCallPipeline.Call) {
  withContext(myContext){
   proceed()            
  }
}
Copy code
PipelineContext.proceed()