Dear monks,
is there a sane way how to get rid of "unnecessary" part of URL path, while avoiding the matching conflict? Imagine chained URLs (paths) like:
It is easy to implement them as chained URIs/region/REGION /category/CATEGORY /region/REGION/.... /category/CATEGORY/...
sub load_region : Chained('/') : PathPart('region') : CaptureArgs(1) { ... } sub view_region : Chained('load_region') : PathPart('') : Args(0) { ... } sub load_category : Chained('/') : PathPart('category') : CaptureArgs( +1) { ... } sub view_category : Chained('load_category') : PathPart('') : Args(0) +{ ... }
Now I would like to get rid of region and category path parts. The range of values for REGION and CATEGORY are disjunct and the values are known so I know that /czech deals with region, while /cosmetics is about category. I can strip the PathPart.
sub load_region : Chained('/') : PathPart('') : CaptureArgs(1) { ... } sub view_region : Chained('load_region') : PathPart('') : Args(0) { ... } sub load_region : Chained('/') : PathPart('') : CaptureArgs(1) { ... } sub view_region : Chained('load_region') : PathPart('') : Args(0) { ... }
but it leads to the conflict, because there is no code to resolve whether the first path part is region or category.
Earlier I tried to redefine match on load_region, but unsuccessfully. As far as I understand Catalyst::DispatchType::Chained the $action->match is called only for the last action of the chain, i.e on view_region.
Do you know any way how to enforce matching on captures for intermediate actions of the chain?
I think that this type of URLs is quite common, for example URLs where the first part of path is a language.
I appreciate any advice including why it is unwise to strip path parts.
In reply to Catalyst - chained actions with empty PathPart by roman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |