mp
04/11/2018, 3:38 PMPipelineInterceptor
?) handle processing for a given path.Deactivated User
04/11/2018, 4:06 PMmp
04/11/2018, 4:07 PMInjector
for it if appropriateDeactivated User
04/11/2018, 4:15 PMHelloRoutes
from the dice example is that you have to declare routes in code instead of with methods?
Your objective is being able to call those methods/routes directly for testing?mp
04/11/2018, 4:20 PMget("/foo", someInstance)
.HelloRoutes
approach is that it leaks this
before construction is finished, which is a thread safety problem.ktor-springer
is definitely interesting, and I'm glad to see the ktor model is flexible enough to support that (even in an experimental way)suspend
closure being passed to get()
and friends with an instance of a class.Deactivated User
04/11/2018, 4:27 PMclass HelloRoutes @Inject constructor(application: Application, @Named("hello-message") message: String) {
init {
application.routing {
get("/") { root() }
}
}
suspend fun PipelineContext<Unit, ApplicationCall>.root() {
// ...
}
}
mp
04/11/2018, 4:28 PMinit
runs after the write barrier for final fields, then it should be safe.Deactivated User
04/11/2018, 4:30 PMmp
04/11/2018, 4:32 PMHelloResource
-style piggybacking on top of Guice's instantiation to register with the Application
is a little unintuitive IMO but nothing I can't get used to, and it certainly has the real benefit of being very explicit. You have somewhere to put breakpoints, etc, and that's always a problem with annotation-based approaches.Deactivated User
04/11/2018, 4:45 PMinit {
application.routing {
get("/") { root(call) }
}
}
suspend fun root(call: ApplicationCall) {
call.respondText("HELLO")
}