[Dancer-users] route classes
Puneet Kishor
punk.kish at gmail.com
Mon Apr 23 16:47:26 CEST 2012
Is it possible to create route classes in a base module and then have all derived instance routes inherit from the parent class? Kinda like so --
use Dance;
get '/' => sub {
my $name = param 'name';
return "name is required for all GETs" unless $name;
};
post '/' => sub {
my $id = param 'id';
return "id is required for all POSTs" unless $id;
};
----
use MyDance;
use base 'Dance';
get '/' => sub {
my $foo = param 'foo';
.. do something with $foo and $name but only if $name is defined ..
};
For bonus points, it would be nice to have base route classes only for routes that end with a '.:format'. For example, only for routes that request 'resource.json'
Is the above possible?
--
Puneet Kishor
More information about the Dancer-users
mailing list