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

Ian

02/10/2019, 4:05 PM
For routing, why did Ktor go with
"/mouse/{id}"
rather than
"/mouse/:id"
, which seems a little more common?
o

orangy

02/10/2019, 4:35 PM
There are couple of reasons. One is that it looks a bit like string interpolation. Another is prefix/suffix, e.g.
foo-{id}-bar
, it’s easier to separate name of path-param from the rest of the text. One more is that we planned to support typed params, like
{id:Int}
or something, but didn’t really design and implement it (yet).
👍 6
i

Ian

02/10/2019, 5:54 PM
Ah, I didn’t think of the prefix/suffix thing. Thank you, that’s helpful. I’m implementing something similar for routing in https://kweb.io/, and didn’t want to reinvent the wheel unnecessarily.
If interested, here is the result of my efforts: https://docs.kweb.io/en/latest/routing.html