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

Clayton Scott clayton.scott at gmail.com
Thu Mar 4 09:53:43 EST 2010


On Thu, Mar 4, 2010 at 9:25 AM, Brad Van Sickle <bvansickle3 at gmail.com> wrote:
> Tangential discussion on this... but what is the value in using
> dispatching modules like CAP::Routes and CGI::Application::Dispatch?


The big advantage for me when I decided to use CAP::Routes for a project
was because a route is a declaration of what the url looks like and it
will unpack
variables out of the url for me, instead of messing with PATH_INFO myself.

For example
       $self->routes([
             '/contacts/:action/?contact_id' => 'contact_create_update_delete'
       ]);

is describes the url better than:
$self->runmodes({ 'contact_cud' => \&contact_create_update_delete});

Especially when you are performing ajax queries and the like you want to know
what the url looks like and what runmode will be called.

Clayton

P.S. I've had great success in using CAP::Dispatch and CAP::Routes together
my instance script loaded a bunch of CGI::App based modules and used
CAP::Dispatch
to assign root urls for each module (/contacts, /staff, /etc) then I
used CAP::Routes to define the
different url/variable/runmode combinations within each Application.


-- 

Clayton Scott
clayton.scott at gmail.com


More information about the cgiapp mailing list