Right now I have: ```val kodein = Kodein.direct { ...
# ktor
d
Right now I have:
Copy code
val kodein = Kodein.direct {
     .....
}

fun Routing.someController(
		someRepository: SomeRepository
) { ... }

fun Application.module() {
      routing {
        someController(kodein.instance())
    }
}
But I want to be able to access the
kodein
instance inside the
Application.module()
in a way that I can replace it in my tests... @Deactivated User?
1
📝 1
The idea is that your module, or either has
@JvmOverloads
or calls to another function receiving the dependencies (in your case the kodein instance), and then call that method in the tests
d
It might be nice to add that to the testing docs... it took a while till I found the sample. I think using DIs is a common pattern, and knowing how to apply them in Ktor would be nice. Also, I prefer injecting only the necessary things into the particular route functions (which I called controllers) and not pass Kodein around everywhere... I feel it helps alot in decoupling which might also be nice to integrate into the Kodein sample... but in the end that sample saved me thanks 🙂
👌 1
b
Ktor doesn't prevent you from doing regular OOP
d
Right, but it complicates things a bit, I started with Controllers that were classes, but found myself writing a whole layer to duplicate existing functionality... that's why Ktor isn't Spring, it's a DSL based framework @bdawg.io 😉
b
I'll grab a gist of what I really meant by my comment when I get to work haha
👍🏼 1