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

rocketraman

05/28/2019, 9:51 PM
I've got these two routes:
Copy code
/foo:{bar}/{baz}
/{bar}/{baz}
When calling
/foo:123/456
I was expecting the first route to trigger with bar=123 and baz=456. Instead, the second route triggers with bar=foo:123 and baz=456. Is this a bug or expected?
d

Dominaezzz

05/28/2019, 10:20 PM
Interesting, does the order of declaration change anything?
r

rocketraman

05/28/2019, 10:21 PM
Didn't try, I assumed the first one would take priority if it mattered. The trace just shows both routes as matching, and doesn't indicate any type of ordered resolution.
m

mp

05/28/2019, 10:26 PM
Don’t have routes that overlap? 🤷‍♂️ Even if you manage to configure this so it works, the next human that looks at the system is probably going to be confused one way or another
r

rocketraman

05/28/2019, 10:27 PM
Its actually not that confusing in the actual implementation, due to the naming i.e. the second route has completely different param names.
That being said, yeah, I've already changed the route to
/foo/{bar}/{baz}
but due to the nature of the
bar
value this actually makes a lot less sense.
m

mp

05/29/2019, 1:28 AM
ah well. HTTP has its limitations 😕
r

rocketraman

05/29/2019, 2:03 AM
It does indeed, but I'm not sure this case falls into that category. I'm not going to lose sleep over it though :)
Ok, I did lose a little sleep over it 🙂 I found the issue a bit more nuanced than I earlier reported -- the second path is only chosen first if it is surrounded in an
authenticate
block (perhaps other wrappers too, I didn't check). Created this issue: https://github.com/ktorio/ktor/issues/1158
m

mp

05/29/2019, 5:52 PM
interesting
2 Views