You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Matisse Enzer <me...@apple.com> on 2012/01/14 18:57:08 UTC
Overriding a built-in Apache configuration directive using mod_perl
Is it practical to override a built-in Apache config directive such as 'Require' in a mod_perl Apache module?
I have examined the documentation at:
http://perl.apache.org/docs/2.0/user/config/custom.html#Creating_and_Using_Custom_Configuration_Directives
and it seems like it might work, but I'd like to hear others' opinions before starting work on it.
So, for example, can I have our Apache module provide a custom version of the 'Require' directive, approximately like this:
# Example of overriding 'Require' in a mod_perl Apache module
#
my @directives = (
{ name => 'Require',
func => __PACKAGE__ . '::Require',
req_override => Apache2::Const::OR_ALL,
args_how => Apache2::Const::ITERATE,
errmsg => 'Require Entry1 [Entry2 ... [EntryN]]',
},
);
Apache2::Module::add( __PACKAGE__, \@directives );
sub Require {
my ( $self, $parms, $type, @args ) = @_;
my @translated_args = ($type);
# Custom manipulations of arguments
foreach my $old_style_arg (@args) {
my $new_style_arg
= $self->translate_arg($old_style_arg) push $new_style_arg,
@translated_args;
}
$self->{'Require'} = \@translated_args;
}
Re: Overriding a built-in Apache configuration directive using mod_perl
Posted by Matisse Enzer <me...@apple.com>.
Whoops - this corrects a typo in my example code:
# Example of overriding 'Require' in a mod_perl Apache module
#
my @directives = (
{ name => 'Require',
func => __PACKAGE__ . '::Require',
req_override => Apache2::Const::OR_ALL,
args_how => Apache2::Const::ITERATE,
errmsg => 'Require Entry1 [Entry2 ... [EntryN]]',
},
{ name => 'MyOtherParameter', },
);
Apache2::Module::add( __PACKAGE__, \@directives );
sub Require {
my ( $self, $parms, $type, @args ) = @_;
my @translated_args = ($type);
# Custom manipulations of arguments
foreach my $old_style_arg (@args) {
my $new_style_arg = $self->translate_arg($old_style_arg);
push $new_style_arg, @translated_args;
}
$self->{'Require'} = \@translated_args;
}
On Jan 14, 2012, at 9:57 AM, Matisse Enzer wrote:
> Is it practical to override a built-in Apache config directive such as 'Require' in a mod_perl Apache module?
>
> I have examined the documentation at:
> http://perl.apache.org/docs/2.0/user/config/custom.html#Creating_and_Using_Custom_Configuration_Directives
>
> and it seems like it might work, but I'd like to hear others' opinions before starting work on it.
>
> So, for example, can I have our Apache module provide a custom version of the 'Require' directive, approximately like this:
>
> # Example of overriding 'Require' in a mod_perl Apache module
> #
> my @directives = (
> { name => 'Require',
> func => __PACKAGE__ . '::Require',
> req_override => Apache2::Const::OR_ALL,
> args_how => Apache2::Const::ITERATE,
> errmsg => 'Require Entry1 [Entry2 ... [EntryN]]',
> },
> );
>
> Apache2::Module::add( __PACKAGE__, \@directives );
>
> sub Require {
> my ( $self, $parms, $type, @args ) = @_;
>
> my @translated_args = ($type);
>
> # Custom manipulations of arguments
> foreach my $old_style_arg (@args) {
> my $new_style_arg
> = $self->translate_arg($old_style_arg) push $new_style_arg,
> @translated_args;
> }
> $self->{'Require'} = \@translated_args;
> }
>
>
>