jean
06/24/2021, 7:50 AMAleksei Tirman [JB]
06/24/2021, 9:34 AMApplication
instance then you can install any feature there "dynamically". Here is an example:
val feature = object : ApplicationFeature<ApplicationCallPipeline, Unit, Unit> {
override val key: AttributeKey<Unit> = AttributeKey("MyFeature")
override fun install(pipeline: ApplicationCallPipeline, configure: Unit.() -> Unit) {
pipeline.sendPipeline.intercept(ApplicationSendPipeline.Before) {
println("Requested URL is ${call.request.uri}")
}
}
}
fun main() {
val server = embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
routing {
get("/") {
call.respondText { "root" }
}
}
}
server.start()
server.application.install(feature)
}
jean
06/24/2021, 9:35 AM