aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-03-03 23:57:39 +0100
committerRobert Jaros <rjaros@finn.pl>2020-03-03 23:57:39 +0100
commit2c0d996ed9c69c685b1f1268f0d53778dba818ea (patch)
tree325c80b25ac618a02c54fd95b6f2cca036a91f6e
parent7f7f8b4ed0660fe314a400ea480fbe4cea3c98b5 (diff)
downloadkvision-2c0d996ed9c69c685b1f1268f0d53778dba818ea.tar.gz
kvision-2c0d996ed9c69c685b1f1268f0d53778dba818ea.tar.bz2
kvision-2c0d996ed9c69c685b1f1268f0d53778dba818ea.zip
Default guice bindings for Jooby.
-rw-r--r--kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt13
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)
+ }
+}