The documentation talks about dependency injection, but doesn't really show how to do it.
The documentation is also unfilled and has a bunch of place owners:
http://ktor.io/getting-started.html
I tried to create my main function in such a way that it takes a parameter (which is my dependency), but this failed on the testing side when I call withTestApplication. I looked at the application code and saw that the application is accepting a configuration object, but I have no idea how I can modify this configuration object to inject some dependencies into it.
package org.jetbrains.ktor.application
/**
* Represents configured and running web application, capable of handling requests
*/
class Application(val environment: ApplicationEnvironment) : ApplicationCallPipeline() {
/**
* Called by host when [Application] is terminated
*/
fun dispose() {
uninstallAllFeatures()
}
}
/**
* Convenience property to access log from application
*/
val Application.log get() = environment.log
In the test code with help withTestApplication, I have something similar to the following:
@Test
internal fun myTest() = withTestApplication (Application::myMain)
withTestApplication , myMain (, .)
Update:
, , - , , , / .