You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by jobapply <jo...@nextmail.ru> on 2005/07/26 21:05:11 UTC

Update configuration from directive handler

 
I want to add ServerAlias to all VirtualHosts based on ServerName value and
database information.

First I tried to do it with PostConfigHandler, but tree modification did not
work.
Then I made ServerName handler.

Here I try to set my own ServerName, but that doesn't work.

my @directives = (
      {
       name         => 'ServerName',
       func         => __PACKAGE__ . '::MyParameter',
       req_override => Apache2::Const::OR_ALL,  // sure I can fix
req_override and args_how later
       args_how     => Apache2::Const::ITERATE,
       errmsg       => 'ServerName Entry1 [Entry2 ... [EntryN]]',
      }
);

Apache2::Module::add(__PACKAGE__, \@directives);
  
sub MyParameter {
	my($self, $parms, @arg) = @_;
      
	# leave default host to learn if we succeeded
	if ($arg[0] eq 'default.x') { 
		return DECLINE_CMD; 
	}		
	
	$self->{'ServerName'} = 'bla.x';
      
	return DECLINE_CMD;
}


How to update configuration of current Vhost in directive handler ?
How to change ServerName in my case ?

Thank you!


Re: Update configuration from directive handler

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
jobapply wrote:
>  
> I want to add ServerAlias to all VirtualHosts based on ServerName value and
> database information.
> 
> First I tried to do it with PostConfigHandler, but tree modification did not
> work.
> Then I made ServerName handler.

You probably want to have a PostConfigHandler and modify the configuration tree
with the Apache2::Directive API

http://perl.apache.org/docs/2.0/api/Apache2/Directive.html

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5