[dancer-users] Dancer::Plugin::Auth::Extensible - possible backwards-incompatible change
damien krotkine
dkrotkine at gmail.com
Tue Dec 11 14:10:07 GMT 2012
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 <davidp at preshweb.co.uk> wrote:
> On Tue, 11 Dec 2012 11:40:29 +0000
> Daniel Perrett <dperrett at cambridge.org> 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") <davidp at preshweb.co.uk>
> 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
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20121211/ff01c5b6/attachment.htm>
More information about the dancer-users
mailing list