Hi, The only drawback is performance : there is an additional indirection, and code dereferencing might be costly. The optimization of the route caching stops wher your route code starts, so it won't be optimized. You don't get performance hits ( or less, at least I think) with attributes.
Hm, it could be solved by calling got &$code actually. But be careful about argument passing. On 11 December 2012 13:39, David Precious <[email protected]> wrote: > On Tue, 11 Dec 2012 11:40:29 +0000 > Daniel Perrett <[email protected]> wrote: > > > Perhaps I'm missing something but... > > > > "how requires_login/requires_role would store the fact that the > > provided sub requires auth" > > > > Simple implementation: > > > > # given has_role is calculable > > > > sub requires_role { > > my ($role, $code, $handle_exception) = @_; > > return sub { > > if (has_role($role)){ > > $code->(@_); > > } > > else{ > > if (defined $handle_exception){ > > $handle_exception->($role, @_) > > } > > else { > > default_403_no_role($role, @_) > > } > > } > > } > > } > > Ah, yes - that's pretty clever. I think like that approach - it's > simple and solid. > > Thanks! > > > > -- > David Precious ("bigpresh") <[email protected]> > http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter > www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook > www.preshweb.co.uk/cpan www.preshweb.co.uk/github > > > _______________________________________________ > dancer-users mailing list > [email protected] > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users >
_______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
