You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by André Warnier <aw...@ice-sa.com> on 2009/04/21 12:16:07 UTC

finding "context" in mod_perl handler

Hi.

Supposing I have this kind of setup

<Location /xyz>
   PerlAuthenhandler My::AuthModule
   ...
</Location>

...

<Directory /var/www/some/path>
   PerlAuthenhandler My::AuthModule
   ...
</Directory>

and a request is made for "/xyz", and as a result the module is called,

is there some way in My::AuthModule::handler(), by which I can find out 
that, in *this* instance, I am being called in the "context" of the 
<Location> directive above, as opposed to the <Directory> case ?

I mean, I could do something like respectively
   PerlSetVar context "location:/xyz"
and
   PerlSetVar context "dir:/some/path"

and then check the var in the handler, but there has to be a 
better/cleaner way, no ?

Thanks
André

Re: finding "context" in mod_perl handler

Posted by David Ihnen <da...@norchemlab.com>.
André Warnier wrote:
> Hi.
>
> Supposing I have this kind of setup
>
> and then check the var in the handler, but there has to be a 
> better/cleaner way, no ?
>
> Thanks
> André
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_path_info_

Just get the info from the request object within the handler?

David





Re: finding "context" in mod_perl handler

Posted by Adam Prime <ad...@utoronto.ca>.
André Warnier wrote:
> Hi.
> 
> Supposing I have this kind of setup
> 
> <Location /xyz>
>   PerlAuthenhandler My::AuthModule
>   ...
> </Location>
> 
> ...
> 
> <Directory /var/www/some/path>
>   PerlAuthenhandler My::AuthModule
>   ...
> </Directory>
> 
> and a request is made for "/xyz", and as a result the module is called,
> 
> is there some way in My::AuthModule::handler(), by which I can find out 
> that, in *this* instance, I am being called in the "context" of the 
> <Location> directive above, as opposed to the <Directory> case ?
> 
> I mean, I could do something like respectively
>   PerlSetVar context "location:/xyz"
> and
>   PerlSetVar context "dir:/some/path"
> 
> and then check the var in the handler, but there has to be a 
> better/cleaner way, no ?

The first thing i'd try is checking $r->location.  I'm not sure what 
that does for the Directory instance, but in the Location instance it'll 
return '/xyz'.  I don't know of a comparable way to do the same thing 
with Directory directives.

Adam

Re: finding "context" in mod_perl handler

Posted by Perrin Harkins <ph...@gmail.com>.
On Tue, Apr 21, 2009 at 1:47 PM, Perrin Harkins <ph...@gmail.com> wrote:
> On Tue, Apr 21, 2009 at 6:16 AM, André Warnier <aw...@ice-sa.com> wrote:
>> I mean, I could do something like respectively
>>  PerlSetVar context "location:/xyz"
>> and
>>  PerlSetVar context "dir:/some/path"
>>
>> and then check the var in the handler, but there has to be a better/cleaner
>> way, no ?
>
> That's what I would do.  Easy and foolproof.

Assuming of course that you care about Directory xyz vs Location xyz.
If they're totally different URLs, then checking the location is all
you need.

- Perrin

Re: finding "context" in mod_perl handler

Posted by Perrin Harkins <ph...@gmail.com>.
On Tue, Apr 21, 2009 at 6:16 AM, André Warnier <aw...@ice-sa.com> wrote:
> I mean, I could do something like respectively
>  PerlSetVar context "location:/xyz"
> and
>  PerlSetVar context "dir:/some/path"
>
> and then check the var in the handler, but there has to be a better/cleaner
> way, no ?

That's what I would do.  Easy and foolproof.

- Perrin