Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How to get the value of <Location> directive (mod_perl)?

by ChemBoy (Priest)
on Dec 10, 2006 at 18:17 UTC ( [id://588918]=note: print w/replies, xml ) Need Help??


in reply to How to get the value of <Location> directive (mod_perl)?

I'm not sure this is what you're after, but it seems like it might be a problem I had recently: if your module is handling all of the requests below a certain root URI, and you're taking actions based on the path after that root, how do you know (without hardcoding it or some other such evil tactic) how much of the uri is what you're supposed to be processing?

My solution, which may or may not have been a good one, was to do the Apache configuration in Perl. The root URL for each handler is set in a constants file, and the configuration section refers to that constant when setting up the server. (I can't remember precisely the syntax, but it's roughly $Location{$MY::ROOT_URL} = { PerlResponseHandler=>'My::Apache::Handler', SetHandler=>"perl-script'};) Then the handler itself refers to that same constant when determining its root path: (my $path = $r->uri) =~ s/^\Q$MY::ROOT_URL//;.

If that wasn't the problem you were trying to solve, my apologies, but it seemed like a decent shot. :-)



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders

Replies are listed 'Best First'.
Re^2: How to get the value of <Location> directive (mod_perl)?
by Burak (Chaplain) on Dec 10, 2006 at 19:14 UTC
    It looks like you've revealed my evil action :) But, it seems like your method will also need hardcoding at least in two places. I'm currently using PerlSetVar to set the location:
    <Location /foo> SetHandler perl-script PerlSetVar NAME "/foo" PerlHandler My::Apache::Handler </Location>
    It looks like Apache2::Directive may help, but I still need to know what the location is:
    use Apache2::Directive (); my $tree = Apache2::Directive::conftree(); my $node = $tree->lookup('Location', '/foo/');

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://588918]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found