You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases, it is convenient to have a mechanism for processing parts of a path. E.g. I want to have a hierarchical processing of the path endingphotos/*other. This route would match photos/12 or /photos/long/path/to/12, setting other-segment to "12" or "long/path/to/12".
This way may be used for organizing access to a file storage with additional control functions.
As mentioned in #661 in Genie 6 (currently in the v6 branch) we have some support for this. It's not extensive as Rails' as it's greedy. So for now we only process routes like /foo/bar/* that would match /foo/bar/x, or /foo/bar/x/z etc.
The matching part ends up in params["_"] as x or x/z.
Thanks, this is really good that you implemented this function. At the same time, RoR is still a good sample of how to organize dynamic components of the path. The cases 'books/*section/:title' or '*a/foo/*b' are also sometimes useful. E.g. for the 'books/*section/:title'I can manage a hierarchical taxonomy of sections and request the book by title. In case of '*a/foo/*b' the a can encode the API version, but b be a name of the resource. But no way to have more than one wildcard segment when using '_' variables.
BTW, have you thought about replacing of the for r in routes() with multiple regex checks by a single state machine implemented with something like Automa.jl to avoid performance problems in applications with many paths?
essenciary
changed the title
wild-carded segments in a path
Improvements to wild-carded segments in a path
Sep 7, 2023
In some cases, it is convenient to have a mechanism for processing parts of a path. E.g. I want to have a hierarchical processing of the path ending
photos/*other
. This route would match photos/12 or /photos/long/path/to/12, settingother
-segment to "12" or "long/path/to/12".This way may be used for organizing access to a file storage with additional control functions.
See more examples: https://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
The text was updated successfully, but these errors were encountered: