[Catalyst] Regex dispatch type is deprecated

John Napiorkowski jjn1056 at yahoo.com
Wed Jul 8 13:52:41 GMT 2015


As far as I see this controller still works (I didn't even know about it...)  It seems to do something a little different from the built in, which is it seems to want to return error messages (I can't really tell to be honest).  The built in support will just fail to match, so if you want a 'didn't match' response you;d need to add a catchall or less restrictive constraint to the same route.

Personally it doesn't do anything I need and its a bit old (uses NEXT and some other bits I'd like to see die from Catalyst support) but I have no current plan to break stuff that already works :)  You should try it and try the built in support and see what works best for you.   If you have code that works with this again I have no plan to break this but I'd consider for new stuff to see if the built in support does what you need (and if it doesn't consider contributing to that)


On Wednesday, July 8, 2015 4:13 AM, Craig Chant <craig at homeloanpartnership.com> wrote:
Hi Jon,

Does that mean we shouldn't be using : http://search.cpan.org/~phaylon/Catalyst-Controller-Constraints-0.10_02/lib/Catalyst/Controller/Constraints.pm



-----Original Message-----
From: John Napiorkowski [mailto:jjn1056 at yahoo.com]
Sent: 07 July 2015 19:51
To: The elegant MVC web framework
Subject: Re: [Catalyst] Regex dispatch type is deprecated


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

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) = @_;


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!


On Tuesday, July 7, 2015 10:42 AM, Dmitry Karasik <dmitry at 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 at 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 at 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/
This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable steps to try to identify any software viruses, any attachments to this e-mail may nevertheless contain viruses, which our anti-virus software has failed to identify. You should therefore carry out your own anti-virus checks before opening any documents. HomeLoan Partnership will not accept any liability for damage caused by computer viruses emanating from any attachment or other document supplied with this e-mail. HomeLoan Partnership reserves the right to monitor and archive all e-mail communications through its network. No representative or employee of HomeLoan Partnership has the authority to enter into any contract on behalf of HomeLoan Partnership by email. HomeLoan Partnership is a trading name of H L Partnership Limited, registered in England and Wales with Registration Number 5011722. Registered office: Pharos House, 67 High Street, Worthing, West Sussex, BN11 1DN. H L Partnership Limited is authorised and regulated by the Financial Conduct Authority.

More information about the Catalyst mailing list