new()
CONSTRUCTOR
HTML::Mason::ApacheHandler - Mason/mod_perl interface
use HTML::Mason::ApacheHandler;
my $ah = new HTML::Mason::ApacheHandler (..name/value params..); ... sub handler { my $r = shift; $ah->handle_request($r); }
The ApacheHandler object links Mason to mod_perl, running components in
response to HTTP requests. It is controlled primarily through
parameters to the new()
constructor.
handle_request()
is not a user method, but rather is called from the
HTML::Mason::handler() routine in handler.pl.
new()
CONSTRUCTORCGI.pm
or
Apache::Request
object (respectively) will be created for the purposes
of argument handling.
'mod_perl' is the default and requires that you have installed the
Apache::Request
package.
If the args_method is 'CGI', the Mason request object ($m
) will have a
method called cgi_object
available. This method returns the CGI
object used for argument processing.
If args_method is '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
for more information.
While Mason will load Apache::Request
or CGI
as needed at runtime, it
is recommended that you preload the relevant module either in your
httpd.conf or handler.pl file, as this will save some memory.
FORBIDDEN
error as appropriate. See the allowing directory requests section of the administrator's manual
for more information about handling directories with Mason.
All of the above properties, except interp_class, have standard accessor methods of the same name: no arguments retrieves the value, and one argument sets it, except for args_method, which is not settable. For example:
my $ah = new HTML::Mason::ApacheHandler; my $decline_dirs = $ah->decline_dirs; $ah->decline_dirs(1);
The ApacheHandler object has a few other publically accessible methods that may be of interest to end users.
exec
method to have it generate output.
If this method returns an Apache status code, that means that it could not create a Mason request object.
This method is useful if you would like to have a chance to decline a request based on properties of the Mason request object or a component object. For example:
my $req = $ah->prepare_request($r); # $req must be an Apache status code if it's not an object return $req unless ref($req);
return DECLINED unless $req->request_comp->source_file =~ /\.html$/;
$req->exec;
The second is an Apache request object, possibly the one originally passed to the method.
The third item may be a CGI.pm object or undef
, depending on the
value of the args_method parameter.