Mark Hedges

NAME

Apache2::Controller::Dispatch::HashTree - Hash tree dispatch for Apache2::Controller::Dispatch

VERSION

Version 1.001.001

SYNOPSIS

 <Location "/subdir">
     SetHandler modperl
     PerlInitHandler MyApp::Dispatch
 </Location>

 # lib/MyApp::Dispatch:

 package MyApp::Dispatch;
 use base qw(
     Apache2::Controller::Dispatch::HashTree
 );

 # return a hash reference from dispach_map()
 sub dispatch_map { return {
    foo => {
        default     => 'MyApp::C::Foo',
        bar => {
            biz         => 'MyApp::C::Biz',
            baz         => 'MyApp::C::Baz',
        },
    },
    default => 'MyApp::C::Default',
 } }

 1;
 __END__

This maps uri's to controller modules as follows:

 /subdir/foo                    MyApp::C::Foo->default()

 /subdir/foo/bar                MyApp::C::Foo->bar()

 /subdir/foo/bar/zerm           MyApp::C::Foo->bar(), path_args == ['zerm']

 /subdir/foo/bar/biz            MyApp::C::Biz->default()

 /subdir/foo/biz/baz/noz/wiz    MyApp::C::Baz->noz(), path_args == ['wiz']

In the second example, if <MyApp::C::Foo> did not implement or allow <bar()> as a controller method, then this would select <MyApp::C::Foo-default()>>.

DESCRIPTION

Implements find_controller() for Apache2::Controller::Dispatch with a simple hash-based mapping. Uses substr to divide the uri and exists to check cached mappings, so it should be pretty fast.

This dispatches URI's in a case-insensitive fashion.

METHODS

find_controller

Find the controller and method for a given URI from the data set in the dispatch class module.

SEE ALSO

Apache2::Controller::Dispatch

Apache2::Controller::Dispatch::Simple

Apache2::Controller

AUTHOR

Mark Hedges, hedges +(a t)| formdata.biz

COPYRIGHT AND LICENSE

Copyright 2008-2010 Mark Hedges. CPAN: markle

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

This software is provided as-is, with no warranty and no guarantee of fitness for any particular purpose.