Replies: 4 comments 1 reply
-
@jchavarri This is indeed a little awkward to deal with with the current API. The current trunk contains support for wildcard matches at the end of the route that might help here. So you would define the route as
This might be a little nicer than writing multiple routes to get the functionality you need. That said, I think there is room for improvement over what happens with the |
Beta Was this translation helpful? Give feedback.
-
Yeah, I have tried with wildcard and it works great with the "optionality" part and trailing slashes, but it's too broad for my use case, where all segments are known beforehand. I will see if I can remove the optionality for now. I guess the building block I'm missing is some kind of helper that allows to either match against Thanks! |
Beta Was this translation helpful? Give feedback.
-
It might be interesting to explore some helpers that make this use-case easier. At the moment the choice between trailing slash vs non trailing slash is explicit via |
Beta Was this translation helpful? Give feedback.
-
@jchavarri This is two years later, but routes 2.0.0 moved to a new way of handling trailing slashes that might make this use-case easier to work with. There are no separate https://ocaml.org/p/routes/2.0.0/doc/Routes/index.html#type-match_result |
Beta Was this translation helpful? Give feedback.
-
I have a route that can have the following shapes:
foo/:id
foo/:id/bar
foo/:id/baz
And the same routes with trailing slash.
I am trying to put all of these under a single path. So I defined a pattern for
bar
andbaz
, like:Then I define the path as
s "foo" / id / last /? nil);
However, this means that I can't match over
foo/:id
, but only overfoo/:id/
, with the trailing slash.Is it possible to achieve this without defining two paths?
Beta Was this translation helpful? Give feedback.
All reactions