[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MP2][QUESTION]Adding handlers when defining a new directive
- Subject: [MP2][QUESTION]Adding handlers when defining a new directive
- Date: Tue, 29 Apr 2008 10:50:29 +0200
- From: "titetluc titetluc" <suppressed>
Hello,
I am writing a new mod_perl Apache (mod_perl2) to manage session tracking and SSO
This module defines a new Apache directive (MyNewDirective), which is usable in a <location>, <files><directory> block.
For example
<Location /a_test>
Set-Handler perl-script
MyNewDirective a_test arg1 arg2
PerlResponseHandler ResponseHandlerToTestTheNewDirective
</Location>
<Location /another_test>
Set-Handler perl-script
PerlResponseHandler ResponseHandlerToTestTheNewDirective
</Location>
When this directive is used, my module should a PerlLogHandler automatically to obtain the following configuration
<Location /a_test>
Set-Handler perl-script
MyNewDirective a_test arg1 arg2
PerlResponseHandler ResponseHandlerToTestTheNewDirective
PerlLogHandler TestPerlLogHandler
</Location>
<Location /another_test>
Set-Handler perl-script
PerlResponseHandler ResponseHandlerToTestTheNewDirective
</Location>
I tried to use the push_handler method when the 'MyNewDirective' is defined.
my @directives = ({name => 'MyNewDirective ', func => __PACKAGE__.'::MyNewDirective'});
Apache2::Module::add(__PACKAGE__, suppressed);
sub MyNewDirective {
my ($self, $parms, $arg) = @_;
# blablabla
$parms->server->push_handlers(PerlLogHandler => sub {my ($r) _ @_; $r->server->error_log('hello world'); return Apache2::Const::OK;});
# blablabla
return;
}
This code works ... but for any blocks.
For example, if I access the URI '/a_test', the PerlLogHandler will be called BUT if I access the URI '/another_test', the PerlLogHandler will also be called.
Do I use the mod_perl API correctly ?
What is wrong in my code ?
Thanks.
Gaetan
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.