John, Thank you very much! That was exactly what I needed
On Tue, Jul 07, 2015 at 06:51:08PM +0000, John Napiorkowski wrote: > Dmitry, > > You can use the Regexp Dispatcher on CPAN, for legacy code. There is no plan > to stop supporting it, unless we hit a point where we can't support it when > making required fixes to Catalyst. I just wanted to remove it from Catalyst > core such as to emphasis its no longer the approved approach and prevent > people from writing new code with it. > > If you are using the newest Catalyst, we added Type Constraint matching to > Args and this should let you dispatch on regexp types in a very similar > manner. Take a look at > > > https://metacpan.org/pod/distribution/Catalyst-Runtime/lib/Catalyst/RouteMatching.pod#Using-type-constraints-in-a-controller > which has an example of using a regular expression type constraint generator > is a way that functions similarly to how the old regexp worked. For example: > > > package MyApp::Controller::User; > > use Moose; > use MooseX::MethodAttributes; > use Types::Standard qw/StrMatch/; > > extends 'Catalyst::Controller'; > > sub looks_like_a_date :Path('') Args(StrMatch[qr{\d\d-\d\d-\d\d\d\d}]) { > my ($self, $c, $date) = @_; > } > > __PACKAGE__->meta->make_immutable; > > > requires a URL like /user/11-11-2222 > That is one approach, or you can create custom ActionRoles for special > dispatch rule needs. In general I think the new feature to add type > constraint checks on Args and CaptureArgs gives you everything you had with > regexp and more. Feedback, and bug fix patches welcomed! > > Jnap > > > > On Tuesday, July 7, 2015 10:42 AM, Dmitry Karasik <dmi...@karasik.eu.org> > wrote: > > > > Hello all, > > I'm upgrading an older Catalyst installation, and re-writing code that uses > Regex/LocalRegex dispatchers. The rewriting is mostly for routes such as > Regex('a-(\d+)-(\d+).png'), and I'm writing new code which basically does the > same, but using :Args(1), manually matching the last part of url, and > detaching > to new route with matched parameters. This is not a problem, but I'm thinking > that I must be not the only one having the same problem, and there must be a > module on CPAN that dispatches execution using regexes, as a replacement. But > Catalyst::DispatchType::Regex that seems to be the offical replacement, warns > about the > Regex/LocalRegex attributes are deprecated, which is confusing to me -- the > feature was removed from the core, okay, but I still want to use it through a > separate module, why then warn about deprecation again? > > So basically my question is, what's the best recommended way to rewrite > requests such as a-2-3.png, for example? Or, how could I rewrite these > requests > with chaining? > > -- > Thank you, > Dmitry Karasik > > > _______________________________________________ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > > _______________________________________________ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ -- Sincerely, Dmitry Karasik _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/