Apache2::Controller::DispatchDispatch base class for Apache::Controller | |
Download |
Apache2::Controller::Dispatch Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Mark Hedges
- Publisher web site:
- http://search.cpan.org/~markle/
Apache2::Controller::Dispatch Tags
Apache2::Controller::Dispatch Description
Dispatch base class for Apache::Controller Apache2::Controller::Dispatch is a Perl module that forms the base for the PerlInitHandler module to dispatch incoming requests to libraries based on their URL.SYNOPSISSynopsis examples use Apache2::Controller::Dispatch::Simple, but you may want to check out Apache2::Controller::Dispatch::HashTree or write your own. All use the A2C_Dispatch_Map directive, but the hash structure differs between subclasses.EASY WAYThis only works if you have one website on the whole server (under forked mpm) because the intepreter only loads the module once and then it won't load another dispatch map for other uri's. # vhost.conf: < Location / > SetHandler modperl A2C_Dispatch_Map /path/to/yaml/syck/dispatch/hash/file.yaml PerlInitHandler Apache2::Controller::Dispatch::Simple < /Location >NORMAL WAYThe normal way supports many separate dispatch maps on a server, but each application must subclass a dispatch class, even if it has no methods. # vhost.conf: PerlLoadModule MyApp::Dispatch; < Location / > SetHandler modperl A2C_Dispatch_Map /etc/myapp/dispatch.yaml PerlInitHandler MyApp::Dispatch < /Location > # /etc/myapp/dispatch.yaml: foo: MyApp::Controller::Foo bar: MyApp::Controller::Bar biz: MyApp::C::Biz 'biz/baz': MyApp::Controller::Biz::Baz # lib/MyApp/Dispatch.pm: package MyApp::Dispatch; use base qw( Apache2::Controller::Dispatch::Simple ); 1;HARD WAY # vhost.conf: PerlModule MyApp::Dispatch < Location / > SetHandler modperl PerlInitHandler MyApp::Dispatch < /Location > # lib/MyApp/Dispatch.pm: package MyApp::Dispatch; use strict; use warnings FATAL => 'all'; use base qw( Apache2::Controller::Dispatch::Simple ); # return a hash reference from dispatch_map() sub dispatch_map { return { foo => 'MyApp::C::Foo', bar => 'MyApp::C::Bar', biz => 'MyApp::C::Biz', 'biz/baz' => 'MyApp::C::Biz::Baz', } } # or use directive A2C_Dispatch_Map to refer to a YAML file. 1; Requirements: · Perl
Apache2::Controller::Dispatch Related Software