[cgiapp] Re: Patches available for ::Plugin::Routes (was: Re: New plugin idea based/inspired on CA Dispatch)

Mark Stosberg mark at summersault.com
Wed Oct 8 10:23:42 EDT 2008


> http://search.cpan.org/~porta/CGI-Application-Plugin-Routes-0.02/
> 
> 0.02 should be working ok. After I uploaded 0.01 I've noticed I forgot
> to include the README into the package and the tests failed.
> Enjoy and thanks for the help.

Thanks, Julian.

Today I noticed another new routing system being developed for a Perl 
based web framework. The syntax looks like this:

     sub startup {
         my $self = shift;

         # Default routes
         my $r = $self->routes;

         # Test route
         $r->route('/this/is/a/test/:number', number => qr/\d+/)
           ->methods(qw/GET POST/)
           ->to(controller => 'foo', action => 'test', number => 23);

         # Nested route
         my $n = $r->route('/foo')->to(controller => 'test');
         $n->route('/bar')->to(action => 'index');
         $n->route('/baz')->to(action => 'lalala');

         # Default route
         $r->route('/:controller/:action')->to(action => 'index');
    }

###

It shows off a number of features beyond what we are providing:
    - validating URI chunks based on a regular expression
    - limiting URIs to just "GET" or "POST"
    - dispatching to run modes in other modules 
      ( Dispatch.pm does this, while Routes.pm intentionally doesn't )
    - "Nested Routes". It's not clear wheter this example is a different
      way to dispatch "/foo/bar/baz", or just another way to set a
      default "controller" 
    
It's a nice clean looking syntax, but I'm not sure I really "want" these
additional features. 

For example, If validation of the RegEx or the GET/POST validation
fails, what happens?  If it returns a page to the user, can you have
control over how it looks? 

Still, it' an interesting alternative to follow.

Reference:
http://lists.kraih.com/pipermail/mojo/2008-October/000002.html

    Mark

-- 
http://mark.stosberg.com/





More information about the cgiapp mailing list