Hi! I have a question on routing/paths in Ktor. I ...
# ktor
p
Hi! I have a question on routing/paths in Ktor. I have a Ktor server on which I’d like to receive requests on
“/“
and on
“/test”
. The thing is I’d like both to listen also to any extra path segment. The problem is that I can’t listen for
“/*”
and
“/test/*”
because the latter is covered by the first. Does this mean I’d need to use regexes for the path definitions in the routes?
a
You can use the same handler for both of the following routes:
Copy code
routing {
    get("/{...}") {
        // myHandle()
    }
    get("/test/{...}") {
        // myHandle()
    }
}
Or you can use regex routes, as you mentioned.
p
Thanks Alexsei! Let me give that a try 👍🏻