Hey guys. Is there a way to have dynamic routes in...
# ktor
c
Hey guys. Is there a way to have dynamic routes in Ktor server? Routes that can be set in runtime?
a
You can do it by storing a reference to the route and using it to add the child routes. Here is an example:
Copy code
embeddedServer(Netty, 8080) {
    routing {
        val route = this as Route
        get("/add") {
            route.get("/new") {
                call.respondText { "NEW" }
            }

            call.respondText { "OK" }
        }
    }
}.start(wait = true)
Can you please describe your use case for the dynamic routes?
c
We’re trying to build an API gateway for all of our services and we want the services to register themselves securely with their own config. So we want quick reloading without restarting the application