Hi,<br><br>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&#39;t be optimized. You don&#39;t get performance hits ( or less, at least I think) with attributes.<br>
<br>Hm, it could be solved by calling  got &amp;$code actually. But be careful about argument passing.<br><div class="gmail_extra"><br><br><div class="gmail_quote">On 11 December 2012 13:39, David Precious <span dir="ltr">&lt;<a href="mailto:davidp@preshweb.co.uk" target="_blank">davidp@preshweb.co.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, 11 Dec 2012 11:40:29 +0000<br>
Daniel Perrett &lt;<a href="mailto:dperrett@cambridge.org">dperrett@cambridge.org</a>&gt; wrote:<br>
<br>
&gt; Perhaps I&#39;m missing something but...<br>
&gt;<br>
&gt; &quot;how requires_login/requires_role would store the fact that the<br>
&gt; provided sub requires auth&quot;<br>
&gt;<br>
&gt; Simple implementation:<br>
&gt;<br>
&gt; # given has_role is calculable<br>
&gt;<br>
&gt; sub requires_role {<br>
&gt;         my ($role, $code, $handle_exception) = @_;<br>
&gt;         return sub {<br>
&gt;                 if (has_role($role)){<br>
&gt;                         $code-&gt;(@_);<br>
&gt;                 }<br>
&gt;                 else{<br>
&gt;                         if (defined $handle_exception){<br>
&gt;                                 $handle_exception-&gt;($role, @_)<br>
&gt;                         }<br>
&gt;                         else {<br>
&gt;                                 default_403_no_role($role, @_)<br>
&gt;                         }<br>
&gt;                 }<br>
&gt;         }<br>
&gt; }<br>
<br>
</div>Ah, yes - that&#39;s pretty clever.  I think like that approach - it&#39;s<br>
simple and solid.<br>
<br>
Thanks!<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
--<br>
David Precious (&quot;bigpresh&quot;) &lt;<a href="mailto:davidp@preshweb.co.uk">davidp@preshweb.co.uk</a>&gt;<br>
<a href="http://www.preshweb.co.uk/" target="_blank">http://www.preshweb.co.uk/</a>     <a href="http://www.preshweb.co.uk/twitter" target="_blank">www.preshweb.co.uk/twitter</a><br>
<a href="http://www.preshweb.co.uk/linkedin" target="_blank">www.preshweb.co.uk/linkedin</a>    <a href="http://www.preshweb.co.uk/facebook" target="_blank">www.preshweb.co.uk/facebook</a><br>
<a href="http://www.preshweb.co.uk/cpan" target="_blank">www.preshweb.co.uk/cpan</a>        <a href="http://www.preshweb.co.uk/github" target="_blank">www.preshweb.co.uk/github</a><br>
<br>
<br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</div></div></blockquote></div><br></div>