monarch has asked for the wisdom of the Perl Monks concerning the following question:
I want to be able to pass a variable from my httpd.conf into the called mod_perl pages. e.g. set a variable called "sitename" that I can access by calling something like $r->{sitename} or $r->param("sitename").
It is important that the variable is associated with the handler because I am using many virtual web sites (each with their own handler) with Apache on Linux.
Here is the configuration I am presently using for my handler..
<Perl> { package MyMasonHandler_mywebsite; use vars qw(@ISA); push( @ISA, 'HTML::Mason::ApacheHandler' ); my $ah = HTML::Mason::ApacheHandler->new( comp_root => "/home/mywebsite/html", data_dir => "/var/cache/mason/mywebsite", args_method => 'mod_perl', ); sub handler { my ( $r ) = @_; # maybe set something here? # e.g. $r->param("sitename") = "mywebsite"; $ah->handle_request( $r ); } } </Perl> <VirtualHost *:80> ServerName mywebsite DocumentRoot /home/mywebsite/html <Files *.mhtml> SetHandler perl-script PerlHandler MyMasonHandler_mywebsite </Files> </VirtualHost>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing variable from httpd.conf via Apache2::Request or Mason
by perrin (Chancellor) on Apr 26, 2006 at 03:55 UTC | |
by monarch (Priest) on Apr 26, 2006 at 04:16 UTC |