qwert_ukg
08/19/2023, 3:28 AMfun Application.myPlugin() {
routing {
post("/useful") {
val result = <mailto:this@myPlugin.myService.do|this@myPlugin.myService.do>()
call.respond(result)
}
}
}
val Application.myService get() = MyService(this)
class MyService(private val app: Application) {
fun do() { app.environment.config.property("app.i-can-use-app-props-here").getString() }
}
Aleksei Tirman [JB]
08/20/2023, 9:39 AMApplication.myPlugin
method and require only direct dependencies in the constructor of the service:
fun Application.myPlugin(service: MyService) {
routing {
post("/useful") {
val result = service.doIt()
call.respond(result)
}
}
}
class MyService(private val appConfig: ApplicationConfig) {
fun doIt() {
appConfig.property("app.i-can-use-app-props-here").getString()
}
}