Just a reminder, for people that have been hit by initially missing a detail, like me, and at least someone else in this -probably not a bug- report: https://rt.cpan.org/Public/Bug/Display.html?id=104451
If you're using the controller skeleton provided by 'myapp_create.pl controller ...', and want to import Types for Constraints like mentioned by John, be sure to either remove namespace::autoclean from your used modules, or use it properly so it doesn't clean your imported Types :) > -----Original Message----- > From: John Napiorkowski [mailto:jjn1...@yahoo.com] > Sent: 07 July 2015 19:51 > To: The elegant MVC web framework > Subject: Re: [Catalyst] Regex dispatch type is deprecated > > 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! >
_______________________________________________ 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/