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

Brad Van Sickle bvansickle3 at gmail.com
Thu Mar 4 09:25:01 EST 2010


Tangential discussion on this... but what is the value in using 
dispatching modules like CAP::Routes and CGI::Application::Dispatch?

I've looked at them in the past, and I've heard it mentioned many times 
that they are wonderfully useful.. but I've never fully understood why.

Currently I'm using mod_rewrite to implement pretty URL's and mapping 
them to individual instance scripts.  As I understand it, dispatch 
modules do basically the same thing, except they move the config out of 
.htacces/httpd.conf and will allow me to get rid of the instance scripts 
(which I personally don't consider a HUGE benefit)

I think I'm missing something here. Can someone educate me?


P Kishor wrote:
> On Thu, Mar 4, 2010 at 3:33 AM, Mike Tonks <fluffymike at googlemail.com> wrote:
>   
>> I am using CAP::Routes and it works very well for me.
>>
>>     
>
> Thanks for the report. This is good to know, because this proves I
> must be doing something wrong, even though I can't figure out what. I
> am not using ScriptAlias, but am using .htaccess with RewriteConds and
> RewriteRule.
>
> By the way, could you please check if $self->route_dbg works for you?
>
> My one thought is -- perhaps I am not doing anything wrong, but that
> it is my combination of various plugins. I recall (from a while back),
> I think I had identified some clash between CAPRoutes and
> CAPAuthentication, but it could be some other plug in well that seems
> to redefine the runmodes.
>
>
>
>   
>> First off, I am using ScriptAlias to map the url and hide the script
>> name it the url:
>>
>> So I have a few lines in my /etc/apache2/sites-available/app virtual host file:
>>
>>        ScriptAlias /contacts   /var/www/app/cgi-bin/contacts.cgi
>>        ScriptAlias /jobs        /var/www/app/cgi-bin/jobs.cgi
>>        ScriptAlias /titles       /var/www/app/cgi-bin/titles.cgi
>>
>>
>> Then in contacts.cgi:
>>
>> #!/usr/bin/perl -w
>>
>> use strict;
>>
>> use App::Contacts;
>>
>> my $app = App::Contacts->new();
>>
>> $app->run();
>>
>> and finally the run modes in Contacts.pm
>>
>>
>> sub setup
>> {
>>        my $self = shift;
>>
>>        $self->start_mode('view');
>>
>>        $self->routes_root('');
>>
>>        $self->routes([
>>                ''                                                                      => 'view' ,
>>                '/guest'                                                                => 'guest',
>>                '/staff/edit/:id'                                               => 'edit_staff',
>>                '/staff/process/:id'                                    => 'edit_staff_process',
>>                '/:id/address/new'                                              => 'edit_address',
>>                '/:id/address/:id2'                                     => 'edit_address',
>>                '/:id/address/process/:id2'                     => 'edit_address_process',
>>                '/:id/email/process/:id2'                               => 'edit_email_process',
>>                '/:id/email/new'                                                => 'edit_email',
>>                '/:id/email/:id2'                                               => 'edit_email',
>>                '/:id'                                                                  => 'view' ,
>>                ]);
>>
>> etc.
>>
>> Then my urls are e.g.
>>
>> http://mysite/contacts - default page
>> http://mysite/contacts/1234 - view a specific contact record
>> http://mysite/contacts/1234/address/new - add address to a contact record
>>
>> Note that I haven't got the /contacts/ bit in my routes_root - it
>> doesn't seem to need it.
>>
>> I've been using this for 6 months plus now and as I say it works really well.
>>
>> Hope this helps.
>>
>> mike
>>
>> #####  CGI::Application community mailing list  ################
>> ##                                                            ##
>> ##  To unsubscribe, or change your message delivery options,  ##
>> ##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
>> ##                                                            ##
>> ##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
>> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
>> ##                                                            ##
>> ################################################################
>>
>>
>>     
>
>
>
>   


More information about the cgiapp mailing list