use HTML::Mason::ApacheHandler;
my $ah = new HTML::Mason::ApacheHandler (..name/value params..); ... sub handler { my $r = shift; $ah->handle_request($r); }
new()
constructor.
handle_request()
is not a user method, but rather is called
from the HTML::Mason::handler() routine in handler.pl.
use HTML::Mason::ApacheHandler (args_method=>'mod_perl'); use HTML::Mason;
'CGI' is the default and should work on most Perl systems. However, if you have the Apache::Request package (or are inclined to fetch it from CPAN), you might switch to 'mod_perl' for speed and memory efficiency.
When specifying args_method='CGI', the Mason request object ($m) will have
a method called cgi_object
available. This method returns the CGI object used in the ApacheHandler
code.
When specifying args_method='mod_perl', the $r
global is
upgraded to an Apache::Request object. This object inherits all Apache
methods and adds a few of its own, dealing with parameters and file
uploads. See Apache::Request manual page for more information.
See the sending_http_headers of the Component Developer's Guide for details about the automatic header feature.
$ah->handle_request
or left for Apache to handle (generally with a return status of 500). In
HTML mode the handler sends a readable HTML version of the error message to
the client. HTML mode is most useful in combination with batch output mode
for debugging.
$ah->output_mode
will cause $interp->out_mode
to be set appropriately.
The subroutine receives one parameter, the absolute path to the component. It then returns either a true (serve component) or false (reject component). In this example, the predicate rejects requests for components whose name starts with an ``_'' character:
top_level_predicate => sub { $_[0] !~ m{/_[^/]+$}
my $ah = new HTML::Mason::ApacheHandler; my $errmode = $ah->error_mode; $ah->error_mode('html');