Right as I was looking for request scope support i...
# koin
e
Right as I was looking for request scope support in Koin/Ktor, I stumbled over the new
RequestScope
in Koin 4.1. However, I was a bit disappointed when I first tried it because it doesn't provide any access to the actual
ApplicationCall
. My use case would include that I can e.g. derive a current user from the call's principal and inject that current user into new service instances. A possible solution (that so far works for me in a custom plugin) is to pass the current
call
to the created scope object and in turn pass it on to
createScope.
This allows me to use
getSource
in my
scoped
blocks to access the current application call. Would you consider including something like this in the standard
RequestScope
?
👀 1
1
a
Good point, we can pass easily the call to the scope to help you resolve needed data
🙏 1
I can add it to the next RC. It will let you resolve your
ApplicationCall
object
e
Thank you, much appreciated. BTW, you extract the Koin object from
call.application
anyway, so you might not even need to pass it separately anymore.
a
it depends. It avoids you to pass manually it around. This way you have constructor injection with the call: