https://kotlinlang.org logo
#ktor
Title
t

tipsy

11/24/2018, 12:02 PM
does ktor have reverse routing for the dsl?
o

orangy

11/24/2018, 12:09 PM
what do you mean by “reverse routing”?
t

tipsy

11/24/2018, 12:11 PM
if i define an endpoint,
get("/my-path", ::controller)
, can i somehow get the path by asking ktor, using the controller as an argument?
getRoute(::controller)
would return
"/my-path"
o

orangy

11/24/2018, 12:43 PM
not out of the box, no
you can scan the routing tree and find it, if it’s not in a performance critical code
what’s the task at hand, what are you trying to achieve where you need it?
t

tipsy

11/24/2018, 2:27 PM
a typical task would be building a link to one of your controllers. i'm not trying to use it in ktor, i'm just evaluating the usefulness of the feature. it's something i used a lot when i was using the play framework, but no other frameworks seem to implement it.
i think it's a really useful feature, but not a lot of people seem to agree
y

yen

11/25/2018, 7:31 AM
What would the result be if
::controller
is registered to multiple routes?
t

tipsy

11/25/2018, 9:17 AM
Typically the first one
o

orangy

11/25/2018, 9:53 AM
Ah, typed locations. We have it differently