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.
$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.
$r->print
and override the value of $interp->out_method
. The default is 'batch'. If output_mode is specified as undef
, then $interp->out_method
is left untouched.
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 { basename($_[0]) !~ /^_/ }
NOTE: In this example I've used basename()
from the File::Basename
package. Since the top_level_predicate is defined in handler.pl, within HTML::Mason, any such symbols need to be imported into that package. In other words, I
would need a use File::Basename
somewhere below the package HTML::Mason
line in handler.pl
.
my $ah = new HTML::Mason::ApacheHandler; my $errmode = $ah->error_mode; $ah->error_mode('html');