[Dancer-users] (proposal) Re: Routes with captures

Marc Chantreux khatar at phear.org
Tue Jun 1 23:15:01 CEST 2010


hello, 

The last commit on my repo (http://github.com/eiro/Dancer) is able to
run successfully the following code. 

#! /usr/bin/perl
use Modern::Perl;
use Dancer;

for
( [qw/ log core /]
, [qw/ logger Console  /]
, [qw/ warnings 1 /] 
, [qw/ show_errors 1 /]
, [qw/ auto_reload 0 /]
) { set @$_ }

any [qw| get post |]
, qr{
    / (?<class> user | post ) 
    / (?<action> C|R|U|D | create | read | update | delete )
    / (?<id> \d+)
    /? $ 
}x
, sub {
    my $url = url_paren;
    content_type 'text/plain';
    join "\n", map {"$_ = $$url{$_}"} keys %$url;
}; 

any [qw| get post |], qr/.*/, sub { "nothing" };

dance;

I tested it with 

> curl http://localhost:3000/user/C/324
action = C
class = user
id = 324

but there is nothing new in the test suite: this is only a working proof
of concept waiting for code review. beware if you clone my repo: i added
some stuff broking the test suite and which aren't related to this
topic.

Regards.
marc 


More information about the Dancer-users mailing list