CatalystX::TraitFor::Dispatcher::ExactMatch - handle trailing slashes properly
package MyApp; use Catalyst::Runtime 5.80; use Catalyst qw/ -Debug Static::Simple /; use CatalystX::RoleApplicator; __PACKAGE__->apply_dispatcher_class_roles( qw/CatalystX::TraitFor::Dispatcher::ExactMatch/ );
The Catalyst dispatcher doesn't differentiate between:
http://localhost:3000/foo
http://localhost:3000/foo/
Not even with Regex dispatching. Not even by writing a custom dispatch type.
This is apparently a "feature". As far as I'm concerned, it's a bug.
This trait for Catalyst::Dispatcher attempts to perform an exact match, including trailing slashes, ahead of Catalyst's default dispatching. It's not been tested in every possible configuration, but it works for me.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=CatalystX-TraitFor-Dispatcher-ExactMatch.
CatalystX::RoleApplicator, Catalyst::Dispatcher.
Catalyst::Plugin::SanitizeUrl appears to do something similar for pre-Moose versions of Catalyst.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2011, 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install CatalystX::TraitFor::Dispatcher::ExactMatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::TraitFor::Dispatcher::ExactMatch
CPAN shell
perl -MCPAN -e shell install CatalystX::TraitFor::Dispatcher::ExactMatch
For more information on module installation, please visit the detailed CPAN module installation guide.