From 2c0d996ed9c69c685b1f1268f0d53778dba818ea Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 3 Mar 2020 23:57:39 +0100 Subject: Default guice bindings for Jooby. --- .../src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft') diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt index 82ede003..2245e92b 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt @@ -21,8 +21,11 @@ */ package pl.treksoft.kvision.remote +import com.google.inject.AbstractModule import com.google.inject.Module +import com.typesafe.config.Config import io.jooby.AssetSource +import io.jooby.Environment import io.jooby.Kooby import io.jooby.di.GuiceModule import io.jooby.json.JacksonModule @@ -33,6 +36,14 @@ import io.jooby.json.JacksonModule fun Kooby.kvisionInit(vararg modules: Module) { assets("/", "/assets/index.html") assets("/*", AssetSource.create(javaClass.classLoader, "assets")) - install(GuiceModule(*modules)) + install(GuiceModule(MainModule(this), *modules)) install(JacksonModule()) } + +internal class MainModule(private val kooby: Kooby) : AbstractModule() { + override fun configure() { + bind(Kooby::class.java).toInstance(kooby) + bind(Environment::class.java).toInstance(kooby.environment) + bind(Config::class.java).toInstance(kooby.config) + } +} -- cgit