@John
Thanks for the reply, but
PerlAuthenHandler Authen::special
doesn't work. It worked in mod_perl 1, but mod_perl 2 complains that it
can't find Authen/special.pm in @INC.
@André,
Thanks for the reply. I was reluctant to use this solution because of the
OOC orientation of this syntax, but it isn't actually mandatory to define a
class in order to use this. You just have to be aware that the custom
handler will receive the request object as its second argument instead of
the first.
---
package Authen;
sub handler {
my ($r) = @_;
# regular case with $r as the request object
}
sub special {
my (undef, $r) = @_;
# special case with $r as the request object
}
---
PerlAuthenHandler Authen->special
---
Cheers,
Cédric Bertolini
2010/9/27 André Warnier <[email protected]>
> Hi.
>
> You can use
>
> PerlAuthenhandler Your::Module->special
>
> See http://perl.apache.org/docs/2.0/user/coding/coding.html#Techniques
>
>
>
>
> Cédric Bertolini wrote:
>
>> @Michel,
>>
>> Thanks for the reply. As far as I know, Apache2::RequestRec is a module
>> that
>> provides several functions to manage the $request object provided by
>> mod_perl (http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html).
>> It's
>> not really a handler, though most handlers use this module one way or
>> another. I just want to use a different handler than usual, but from the
>> same file, If that's possible.
>>
>> @Nico
>>
>> Thanks for the reply. Deciding on a behavior based on $r->uri or
>> $r->filename in the handler is what I was doing previously, but I'd love
>> to
>> have a solution based the config file instead of the handler itself, for
>> robustness. I will have to stick to this solution if mod_perl doesn't let
>> me
>> provide the name of the handler, though.
>>
>>
>>
>> 2010/9/27 Nico Coetzee <[email protected]>
>>
>> I had a similar requirement. My solution: based on the value of $r->uri()
>>> I
>>> would call the different subs from the main handler() sub. All the other
>>> subs take $r as the first argument and then the rest of the parameters
>>> follow.
>>>
>>> Probably not the best solution, but it worked for me.
>>>
>>> Cheers
>>>
>>> Nico
>>>
>>> 2010/9/27 Cédric Bertolini <[email protected]>
>>>
>>> Hello,
>>>
>>>> I apologize for such a trivial question, but I'd like to use a function
>>>> other than "handler" as a perl handler. According to the doc, it was
>>>> possible in mod_perl 1, but I can't manage to get it to work under
>>>> mod_perl
>>>> 2.
>>>>
>>>>
>>>> Here is an example of my code:
>>>>
>>>> file Authen.pm
>>>>
>>>> sub handler {
>>>>> // regular handling
>>>>> }
>>>>>
>>>>> sub special {
>>>>> // special case
>>>>> }
>>>>>
>>>> file httpd.conf
>>>>
>>>> <Location /perl/>
>>>>> PerlAuthenHandler /lib/Authen
>>>>> </Location>
>>>>> <Location /perl/special-case/>
>>>>> # I want to override the regular case by using "special" instead of
>>>>>
>>>> "handler" in /lib/Authen.pm
>>>>
>>>>> </Location>
>>>>>
>>>> Thanks in advance,
>>>> Cédric Bertolini
>>>>
>>>>
>>>>
>>
>