Use Mason in a CGI environment
Version: 1.40HTML::Mason::CGIHandler is a Perl module to use Mason in a CGI environment.
License: Perl Artistic License
Operating System: Linux
In httpd.conf or .htaccess:
< LocationMatch ".html$" >
Action html-mason /cgi-bin/mason_handler.cgi
AddHandler html-mason .html
< /LocationMatch >
< LocationMatch "^/cgi-bin/" >
< /LocationMatch >
< FilesMatch "(autohandler|dhandler)$" >
Deny from all
< /FilesMatch >
A script at /cgi-bin/mason_handler.pl :
my $h = HTML::Mason::CGIHandler->new
data_dir => '/home/jethro/code/mason_data',
allow_globals => [qw(%session $u)],
A .html component somewhere in the web server's document root:
< %args >
$mood => 'satisfied'
% $r->err_header_out(Location => "http://blahblahblah.com/moodring/$mood.html");
This module lets you execute Mason components in a CGI environment. It lets you keep your top-level components in the web server's document root, using regular component syntax and without worrying about the particular details of invoking Mason on each request.
If you want to use Mason components from within a regular CGI script (or any other Perl program, for that matter), then you don't need this module. You can simply follow the directions in the Using Mason from a standalone script section of the administrator's manual.
This module also provides an $r request object for use inside components, similar to the Apache request object under HTML::Mason::ApacheHandler, but limited in functionality. Please note that we aim to replicate the mod_perl functionality as closely as possible - if you find differences, do not depend on them to stay different. We may fix them in a future release. Also, if you need some missing functionality in $r, let us know, we might be able to provide it.
Finally, this module alters the HTML::Mason::Request object $m to provide direct access to the CGI query, should such access be necessary.