Hey folks :wave: Quick question on the new `create...
# ktor
m
Hey folks 👋 Quick question on the new
createApplicationPlugin
API. More info in 🧵.
We currently have an interceptor in our ktor server that merges custom context data (if any) into the CoroutineContext on
ApplicationCallPipeline.Setup
.
Copy code
pipeline.intercept(customContextPhase) {
    val context = genContext(call)

    if (context != null) {
        withContext(context) {
            proceed()
        }
    } else {
        proceed()
    }
}
Since
withContext()
and
proceed()
are both not directly available to us in
createApplicationPlugin
's scope, do you have any recommendations on a way to achieve this same functionality? Or should we just stick with a pipeline interceptor in this case?
We did successfully create a custom
Hook
that basically does what this interceptor does. But this didn't feel quite right, as the hook ends up doing the plugin's heavy lifting.
a
I think it’s OK to write a hook when you need low-level control over the execution.
🙏 1