CGI::Application::Dispatch is a Perl module to dispatch requests to CGI::Application based objects.
SYNOPSIS
Out of Box
Under mod_perl
< Location /app >
SetHandler perl-script
PerlHandler CGI::Application::Dispatch
< /Location >
Under normal cgi
#!/usr/bin/perl
use strict;
use CGI::Application::Dispatch;
CGI::Application::Dispatch->dispatch();
With a dispatch table
package MyApp::Dispatch;
use base 'CGI::Application::Dispatch';
sub dispatch_args {
return {
prefix => 'MyApp',
table => [
'' => { app => 'Welcome', rm => 'start' },
':app/:rm' => { },
'admin/:app/:rm' => { prefix => 'MyApp::Admin' },
],
};
}
Under mod_perl
< Location /app >
SetHandler perl-script
PerlHandler MyApp::Dispatch
< /Location >
Under normal cgi
#!/usr/bin/perl
use strict;
use MyApp::Dispatch;
MyApp::Dispatch->dispatch();
This module provides a way (as a mod_perl handler or running under vanilla CGI) to look at the path ($r->path_info or $ENV{PATH_INFO}) of the incoming request, parse off the desired module and it's run mode, create an instance of that module and run it.
It currently supports both generations of mod_perl (1.x and 2.x). Although, for simplicity, all examples involving Apache configuration and mod_perl code will be shown using mod_perl 1.x. This may change as mp2 usage increases.
It will translate a URI like this (under mod_perl):
/app/module_name/run_mode
or this (vanilla cgi)
/app/index.cgi/module_name/run_mode
into something that will be functionally similar to this
my $app = Module::Name->new(..);
$app->mode_param(sub {'run_mode'}); #this will set the run mode
Product's homepage
Requirements:
· Perl