Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Handler Chain (based on request method)

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


aaron at daltons

Oct 28, 2009, 9:58 AM

Post #1 of 4 (643 views)
Permalink
Handler Chain (based on request method)

I'm using mod_perl and CGI::Application::Dispatch to create a RESTful
web application. In the one resource, GETs should be sent to the
default handler, and all other requests to the dispatcher. I have tried
using <Limit> and <LimitExcept>, but they do not appear to be working.
The handlers get processed regardless. Here is the current config:

<Location /fs>
<LimitExcept GET>
Allow from All
SetHandler perl-script
PerlHandler BackCAD::Dispatch
</LimitExcept>
<Limit GET>
Allow from All
SetHandler default-handler
</Limit>
</Location>

Is there some way to make this work? Do I need to write some sort of
pre-dispatcher that checks the request method and returns DECLINED if
it's GET? But if it's *not* GET, how do I then pass control on to the
other dispatcher?

Thank you so much for your time and assistance.
Aaron


aw at ice-sa

Oct 28, 2009, 10:12 AM

Post #2 of 4 (608 views)
Permalink
Re: Handler Chain (based on request method) [In reply to]

Aaron Dalton wrote:
> I'm using mod_perl and CGI::Application::Dispatch to create a RESTful
> web application. In the one resource, GETs should be sent to the
> default handler, and all other requests to the dispatcher. I have tried
> using <Limit> and <LimitExcept>, but they do not appear to be working.
> The handlers get processed regardless. Here is the current config:
>
> <Location /fs>
> <LimitExcept GET>
> Allow from All
> SetHandler perl-script
> PerlHandler BackCAD::Dispatch
> </LimitExcept>
> <Limit GET>
> Allow from All
> SetHandler default-handler
> </Limit>
> </Location>
>
> Is there some way to make this work? Do I need to write some sort of
> pre-dispatcher that checks the request method and returns DECLINED if
> it's GET? But if it's *not* GET, how do I then pass control on to the
> other dispatcher?
>
Just by curiosity, what happened to the suggestions I gave you on the
Apache httpd list (apart from the first one, which was to cross-post here) ?

Also, the reason why the above does not work is probably that the
<Limit...> sections are not really full containers. So your SetHandlers
above probably overwrite one another regardless, and only the last one
counts.

Another quick/cheap hack maybe :

> <Location /fs>
> Allow from All
> SetHandler perl-script
> PerlHandler BackCAD::Dispatch
> </Location>

then modify the code of BackCAD::Dispatch to return DECLINED if it's a GET.
Honestly, I've never tried that, and I don't know if then Apache would
process it with its default handler. But it's worth a try maybe.


aw at ice-sa

Oct 28, 2009, 10:16 AM

Post #3 of 4 (607 views)
Permalink
Re: Handler Chain (based on request method) [In reply to]

André Warnier wrote:
>>
> Just by curiosity, what happened to the suggestions I gave you on the
> Apache httpd list (apart from the first one, which was to cross-post
> here) ?
>
Ok, sorry, I see that response to the httpd list just got there.
Maybe better to move the whole discussion here, there is probably more
focused help available.


pharkins at gmail

Oct 28, 2009, 11:07 AM

Post #4 of 4 (610 views)
Permalink
Re: Handler Chain (based on request method) [In reply to]

On Wed, Oct 28, 2009 at 12:58 PM, Aaron Dalton <aaron [at] daltons> wrote:
> I'm using mod_perl and CGI::Application::Dispatch to create a RESTful
> web application.  In the one resource, GETs should be sent to the
> default handler, and all other requests to the dispatcher.  I have tried
> using <Limit> and <LimitExcept>, but they do not appear to be working.

Those are for rejecting requests, not mapping them to handlers. I
would either use mod_rewrite to map the GET requests to a different
location, or make a PerlTransHandler to deal with it.

> Do I need to write some sort of
> pre-dispatcher that checks the request method and returns DECLINED if
> it's GET?

Right, that would be the TransHandler approach.

> But if it's *not* GET, how do I then pass control on to the
> other dispatcher?

You can set the handler for the current request from within the
script. Take a look at the docs for examples. I know you'll find
some if you search for "default-handler" in the mail archives too.

- Perrin

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.