fun Application.ktorMain() {
// set up omitted
val root = feature(Routing)
val allRoutes = allRoutes(root)
val allRoutesWithMethod = allRoutes.filter { it.selector is HttpMethodRouteSelector }
allRoutesWithMethod.forEach {
<http://logger.info|logger.info>("route: $it")
}
}
fun allRoutes(root: Route): List<Route> {
return listOf(root) + root.children.flatMap { allRoutes(it) }
}
is there another approach to do it ?
👍 1
👀 1
a
Aleksei Tirman [JB]
09/02/2021, 7:58 AM
@Rustam Siniukov do you know any better way?
r
Rustam Siniukov
09/02/2021, 9:50 AM
There is no built in API for that. What is your use case?
u
Undervoid
09/02/2021, 10:06 AM
I’m trying to build a configuration page which allowed user to change the call response for all route requests.
so I need to get list of routes on service startup then display them in the front page