Marc Knaup
07/30/2021, 10:40 AMinstall()
to intercept the call.Aleksei Tirman [JB]
07/30/2021, 11:24 AMfun main() {
embeddedServer(Jetty, port = 8090) {
install(WebSockets)
routing {
validateURLParams {
webSocket("/") {
send(Frame.Text("hello"))
for (msg in incoming) {
println((msg as Frame.Text).readText())
}
}
}
}
}.start(true)
}
fun Route.validateURLParams(build: Route.() -> Unit): Route {
val route = createChild(MyRouteSelector())
route.intercept(ApplicationCallPipeline.Features) {
// if (!parametersValid()) {
call.respond(HttpStatusCode.NotFound)
finish()
// }
}
route.build()
return route
}
class MyRouteSelector : RouteSelector() {
override fun evaluate(context: RoutingResolveContext, segmentIndex: Int): RouteSelectorEvaluation {
return RouteSelectorEvaluation(true, RouteSelectorEvaluation.qualityTransparent)
}
}
Marc Knaup
08/03/2021, 11:37 AMAleksei Tirman [JB]
08/03/2021, 12:06 PMApplicationCallPipeline
?Marc Knaup
08/03/2021, 12:06 PMAleksei Tirman [JB]
08/03/2021, 12:08 PMMarc Knaup
08/03/2021, 12:09 PM