Kodein install as plugin with Ktor
Kotlin-GDE opened this issue · 5 comments
hi
-
how to add kodein in ktor when use configuration file (conf or yaml)
-
install kodein plugin like this:
install(Kodein) {
bind<Type> { ..... }
.....
}
Hi @halimpuckjava ,
perhaps this repository will help you.
https://github.com/ktorio/ktor-samples/tree/main/di-kodein
https://github.com/ktorio/ktor-samples/blob/main/di-kodein/src/main/kotlin/io/ktor/samples/kodein/KodeinSimpleApplication.kt
thanks for reply , i think it help me but i want ti integrate kedein as plugin and install it like other plugins
Hi. Are you looking for a way to install Kodein on a Ktor Server ?
If so, I recommend you to check the docs https://kosi-libs.org/kodein/7.19/framework/ktor.html
TL;DR use the di { … }
builder inside your ktor application.
thanks @romainbsl
yes i see that solution before, but its work with ktor embbeded server, if we work work configure server with .conf or .yml file how can to use this dsl to install kodein ??
Actually, this is not possible to install Kodein through file configuration.
Anyway, you cannot configure your DI context as config file, as we need to read the types, you must do it as code.
Plus, I don't find anything about installing plugins in config files, like install(Sessions)
?