Open jonsecchis opened 3 years ago
Hi, you can use a type to match the prefix, see https://github.com/seanmonstar/warp/issues/19#issuecomment-410392693
Hi, you can use a type to match the prefix, see #19 (comment)
I'm aware of that method, and it is a good one. But is suffers from the problem of fixed arity, since the count of path parameters must be fixed.
I come to the conclusion that a simple regex filter would be the way to go, since it would enable this suffix use case and many many others.
A simple segments(isize)
filter would be nice.
If you pass segments(2)
it'll extract the first 2 segments. and allow path based matching on the rest.
if you pass segments(-2)
it'll extract all segments apart from the last 2.
Can be used to implement suffix. Also the extracted value can be used to determine the "app root" if that's required for the service.
Is your feature request related to a problem? Please describe.
Currently, all routing abstractions are limited by:
So, there is no easy way to match a path based on its suffix if the segments structure is not well known.
Describe the solution you'd like
A method to capture a request based on a path suffix for any arbitrary path structure, such that all of
a.ext
,a/b.ext
andb/c.ext
reach the same route.