メインコンテンツまでスキップ

Ktor & Koin 分離コンテキスト (Isolated Context)

koin-ktorモジュールは、Ktorに依存性注入を提供することに特化しています。

Isolated Koin Context Plugin

KtorでIsolated Koinコンテナを起動するには、次のようにKoinIsolatedプラグインをインストールします。

fun Application.main() {
// Install Koin plugin
install(KoinIsolated) {
slf4jLogger()
modules(helloAppModule)
}
}
警告

Isolated Koinコンテキストを使用すると、Ktorサーバーインスタンスの外部でKoinを使用できなくなります(例:GlobalContextを使用するなど)。