Is there a way to print all Ktor routes for debugg...
# ktor
m
Is there a way to print all Ktor routes for debugging?
j
Yes
I was looking for a post that mentioned this earlier, but can't find it that quick
here is the code that I use for this purpose
Copy code
val root = feature(Routing)
    val allRoutes = allRoutes(root)
    val allRoutesWithMethod = allRoutes.filter { it.selector is HttpMethodRouteSelector }
    allRoutesWithMethod.forEach {
        println("route: $it")
    }
m
Thanks, I’ll check it out 🙏
j
Copy code
fun allRoutes(root: Route): List<Route> {
    return listOf(root) + root.children.flatMap { allRoutes(it) }
}
perhaps this is a good addition 🙂