diff options
author | Robert Jaros <rjaros@finn.pl> | 2020-03-03 23:57:39 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2020-03-03 23:57:39 +0100 |
commit | 2c0d996ed9c69c685b1f1268f0d53778dba818ea (patch) | |
tree | 325c80b25ac618a02c54fd95b6f2cca036a91f6e /kvision-modules/kvision-server-jooby | |
parent | 7f7f8b4ed0660fe314a400ea480fbe4cea3c98b5 (diff) | |
download | kvision-2c0d996ed9c69c685b1f1268f0d53778dba818ea.tar.gz kvision-2c0d996ed9c69c685b1f1268f0d53778dba818ea.tar.bz2 kvision-2c0d996ed9c69c685b1f1268f0d53778dba818ea.zip |
Default guice bindings for Jooby.
Diffstat (limited to 'kvision-modules/kvision-server-jooby')
-rw-r--r-- | kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt | 13 |
1 files changed, 12 insertions, 1 deletions
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) + } +} |