How do I make this locations match? The first shou...
# ktor
d
How do I make this locations match? The first should match alphanumeric, and the second should match integers
l
Is there a way to define priority?
m
I’m just guessing here: probably to Ktor a String path variable will match everything, so it stops. Maybe declaring the {id} first will make it try to parse an integer and pass to the next if it fails… but yeah it’s not a robust way.
d
I tired that, but didn't work
🙁 1
It didn't work for both cases
If I switch positions, the second match fails
m
perhaps this is the feature that could help you: https://ktor.io/docs/routing.html#extensibility
sorry I missed a sentence:
Path parsing is not extensible.
😞
d
Alright thanks, I'll try that and let you know the outcome
Thanks very much
m
I’m starting to suspect that the only way to solve this is to match a generic {id} path and inside the routing function have a factory create either SlugOne or IdOne depending on a regex. Maybe it’s solvable only by code…
you’re welcome, let us know if you make it!
d
@Matteo Mirk have a look at the trace
It says lost in ambiguity tie
And then there's stack trace that, it cannot convert the string into an integer
So an approach by the ktor team, imo, should be instead of throwing away ambiguity ties, it should be kept just in case a first match raises a parse/deserialization error
Until it's resolved, this is what I settled with. Probably this weekend I may try to solve the
Locations
approach and submit an MR
👍 1
m
Cool, that’s probably the only way to solve it for now. My knowledge stops a the trace, I’d have to dig into the path matching code to understand what’s going on. We should really need an authoritative voice from the Ktor team, but no one has answered so far… Maybe open an issue on Ktor repo and see what they say. Thanks for updating me!
d
I already created the issue, but there is no response yet.
👍 1
m
Don’t lose hope, maybe they’ll get to it. Can you share the issue link, I could vote on it, if it helps
d
Haha, thanks.
m
d
this is great. Really appreciate the effort. I'll try and provide a fix and submit a merge request.. and hope they merge it in
🤟 1
🚀 1