Zoltan Demant
04/19/2024, 7:57 AM[X-Debug] = true
for calls from my client, and have my backend inject classes with varying configurations based on it (different api keys). Is my approach sane or do you have any other recommendations?
• Create two scopes that will outlive any route call (I dont want them recreated all the time)
• Check the call header to find the value, then grab the appropiate scope and inject stuff using it
• Preferrably, I can write an extension function that just does all of this so that I can just write by inject<SomeService>()
inside PipelineContext<Unit, ApplicationCall>
Zoltan Demant
04/19/2024, 8:26 AMZoltan Demant
04/19/2024, 8:29 AMcontext(Route)
inline fun <reified T : Any> PipelineContext<*, ApplicationCall>.inject(): Lazy<T> {
val qualifier =
call.request.header(DebugAttribute)?.let { attribute ->
qualifier(attribute)
}
return getKoin().inject<T>(qualifier)
}