You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Xavier <ct...@astola.org> on 2004/11/16 19:18:15 UTC
push_handler with Apache::ModuleConfig
Hello,
for best look, I'd like to replace :
PerlInitHandler My::Module
with
MyModule On
I've done the XS file using Apache::ExtUtils, but I don't know how to
write the "MyModule" sub. Is there any entry in the $cfg object to do it?
sub MyModule {
my($cfg,$parms,$arg)=@_;
$cfg->{__WHAT__} = \&myhandler if($arg);
}
With Google, I've found scripts using "$cfg->{handler}", but they're
calling a standard handler, not a Perl one; I've neither found any doc
about the "per-directory/server" $cfg class.
Thanks.
Xavier
---
French translation of Postfix documentation :
http://x.guimard.free.fr/postfix/
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: push_handler with Apache::ModuleConfig
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Xavier wrote:
> Hello,
>
> for best look, I'd like to replace :
>
> PerlInitHandler My::Module
> with
> MyModule On
these are not the same thing, so they will not have the same effect.
both are parsed and executed only once - when you start the server. well,
ok, twice, but who's counting :) they will also be executed each time you
restart the server.
however, the PerlInitHandler directive tells mod_perl to run My::Module for
each request during the post-read phase. a custom directive will not be
able to do that for you.
>
> I've done the XS file using Apache::ExtUtils, but I don't know how to
> write the "MyModule" sub. Is there any entry in the $cfg object to do it?
>
> sub MyModule {
> my($cfg,$parms,$arg)=@_;
> $cfg->{__WHAT__} = \&myhandler if($arg);
> }
>
> With Google, I've found scripts using "$cfg->{handler}", but they're
> calling a standard handler, not a Perl one; I've neither found any doc
> about the "per-directory/server" $cfg class.
perl directive handlers are _only_ an access to the httpd.conf parsing
process - they do not register your module nor tell it when to run.
therefore you will always need two directives if you want some request-time
action. at least not with mod_perl 1.0 - in mp2 you should be able to use
Apache::Module::add_config to push the PerlInitHandler into the config for you.
see recipes 7.8, 7.10, and 7.11 for a few more examples of using directive
handlers:
http://www.modperlcookbook.org/chapters/ch07.pdf
the code for each of these is also available
http://www.modperlcookbook.org/code/ch07/
HTH
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html