[cgiapp] C::A::P::Routes

Clayton Scott clayton.scott at gmail.com
Thu Mar 4 10:26:31 EST 2010


On Thu, Mar 4, 2010 at 10:04 AM, Brad Van Sickle <bvansickle3 at gmail.com> wrote:
> All of that can be done with mod rewrite.  A (sanitized) example of a
> rewrite/proxy rule I have working in an existing application
>
> RewriteRule Runmode/([0-9]+)/([a-zA-Z0-9]+)
> http://server/perl/instance.pl?rm=Runmode&PARAM1=$1&PARAM2=$2 [P,L]
>
> Which takes the URI "Runmode/20/Data" and turns it into
> "instance.pl?rm=Runmode&PARAM1=20&PARAM2=Data"

I have done and still do the same thing...

> By making use of optional parameters and regular expressions I find it
> to be very powerful and extremely easy.  The fact that I can use
> MOD_PROXY in conjuction with this for load balancing, is also awesome.
> The only downside is that I have to create one of these rules in
> httpd.conf or in .htaccess for each "pretty" URL, but I don't see a way
> of getting around.

CAP::Routes/CAP::Dispatch give you the full ability to do what you want
with regards to regular expressions, but can't handle the MOD_PROXY
stuff for you.

In that case it makes sense to keep all of your "url definitions" in
one place: the apache config.


> Maybe CGI::Application::Dispatch or CAP::Routes is a better/more
> powerful way to do this... but I don't see how.  Which is why I'm asking.

I liked using CAP::Routes/CAP::Dispatch because the URLdefinitions were in
the code that handled them so it was only 1 step to deploy any
changes: push the code.
I prefer that to  push the code, update the rewrite rules, restart apache

Clayton


More information about the cgiapp mailing list