Closed spand closed 1 year ago
First, routing doesn't take into account types of parameters in Location
, so we can reduce it to simple get("…")
:
get("/items/{itemId}/{extra?}") {…}
get("/items/{extra}") {…}
This gives the following routing trie:
items
{itemId}
{extra?}
{extra}
In this case, after items
is matched, there is ambiguity between itemId
and extra
on second part of the path, because they are both of the same quality (parameter capture match). So it simply selects the first item. When itemId
is first, it fails on converting "1-Foo"
to Int, because next level of a tree is optional. When extra
is first and path has more segments, it fails with subtree and goes to the next.
PS: I'm writing some tracing/debugging facility to aid in debugging route matching, thanks for a use case :)
Can you please clarify a few things:
/items/{itemIdInt}
and /items/{extraString}
?PathSegmentParameterRouteSelector
for Int
, Long
, etc that matches only when given String
is parseable, and use it in Locations
./items/id{itemIdInt}
, but for it to be order-independent it needs a little bit of tweaking in match qualities. I.e. match of parameter with prefix/suffix should be valued more than one without it. That sounds like a good change anyway.Thanks for the quick reply. Additionally, is this proper proper usage then ?
get("/items/{itemIdInt}/{extraString}") {…}
get("/items/{extraString}") {…}
Also, what is the reason for allowing installing ambiguous routes ?
This issue has been automatically marked as stale because it has not had recent activity.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
The following testcase passes in 0.4.0 but no longer works in 0.9.1.
So it seems that at some point between these releases something has changed, and there is not much in the CHANGELOG that would indicate this to be expected. I was under the assumption that ordering did not matter but if the
get<OverlappingPath2>
goes first the test passes in 0.9.1.