The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CatalystX::TraitFor::Dispatcher::ExactMatch - handle trailing slashes properly

SYNOPSIS

        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/
                );

DESCRIPTION

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.

BUGS

Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=CatalystX-TraitFor-Dispatcher-ExactMatch.

SEE ALSO

CatalystX::RoleApplicator, Catalyst::Dispatcher.

Catalyst::Plugin::SanitizeUrl appears to do something similar for pre-Moose versions of Catalyst.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2011 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.

DISCLAIMER OF WARRANTIES

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.