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 PMmp
04/11/2018, 4:08 PMmp
04/11/2018, 4:08 PMInjector
for it if appropriatemp
04/11/2018, 4:09 PMmp
04/11/2018, 4:10 PMDeactivated 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?Deactivated User
04/11/2018, 4:18 PMmp
04/11/2018, 4:20 PMget("/foo", someInstance)
.mp
04/11/2018, 4:20 PMHelloRoutes
approach is that it leaks this
before construction is finished, which is a thread safety problem.mp
04/11/2018, 4:22 PMktor-springer
is definitely interesting, and I'm glad to see the ktor model is flexible enough to support that (even in an experimental way)mp
04/11/2018, 4:24 PMmp
04/11/2018, 4:26 PMsuspend
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.mp
04/11/2018, 4:29 PMDeactivated 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")
}