<div id="reply-content">
<br>
</div>
<div id="DA0E3AE467DB4388BDC8DA6C3FB189C4"></div>
<p style="color: #A0A0A8;">Le jeudi 3 janvier 2013 à 16:05, Alexis Sukrieh a écrit :</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<div id="quoted-message-content"><div><div dir="ltr">And then, I raise the Dancer 2 flag:<br><div><br><br><div>2013/1/3 David Golden <span dir="ltr"><<a href="mailto:xdg@xdg.me" target="_blank">xdg@xdg.me</a>></span><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><br></div>
Dancer doesn't (to my knowledge) have a way to have per-route hooks,<br>
or hooks for routes matching some criteria.<br>
<br>
before qr{^/private} => sub { ... };<br>
<br>
(This is the sort of thing that I think Catalyst does with 'begin'<br>
actions in controllers.)<br><br></blockquote><div><br></div><div style="">If you mean Dancer 1, you're right, if you mean Dancer 2, you're wrong.</div><div style=""><br></div><div style="">In Dancer 2, everything is scoped to the "app" it's defined, so doing that is preatty easy with D2:</div>
<div style=""><br></div><div style=""> package SomeApp;</div><div style=""><br></div><div style=""> hook 'before' => sub {</div><div style=""> };</div><div style=""><br></div><div style=""> # some routes</div><div style=""><br></div>
<div style="">In this case, only the routes defined in SomeApp will have the filters defined. Only them. For more details about that feature, I suggest reading that article: <a href="http://advent.perldancer.org/2012/7">http://advent.perldancer.org/2012/7</a></div></div></div></div></div></div></blockquote><div><br></div><div>Hi,</div><div><br></div><div>After reading some emails of people about this scoping, I think we have a hidden issue here:</div><div><br></div><div>Scoping hooks in a package is great and is a must have feature. However, as some people have pointed out it makes it very difficult to quickly add a hook on all routes if they are in multiple packages. </div><div><br></div><div>We should accept that developers have the right to separate features by packages, and not oblige them to group routes and hooks per package. </div><div><br></div><div>Celogeek mentioned that this can be worked around by using roles but not everybody ate fluent with them. </div><div><br></div><div>So, I propose that one could specify the scope of a hook. </div><div><br></div><div>By default a hook would be package-scoped. But we should make it possible to scope it to the whole application ( if that's possible), and also be able to scope it to a selection of routes, as David Golden mentioned. </div><div><br></div><div>Maybe it's not the right solution, but at least you'll agree that there is an issue in the current state ( I think English speaking people say "red herring" :) </div><div> </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><div id="quoted-message-content"><div><div dir="ltr"><div><div>
<div style=""><br></div><div style="">Wouldn't that be a perfect opportunity to try a switch to Dancer 2?</div><div style=""> </div><div style="">PS: you could actually do it in Dancer 1 with a test in the before filter like so:</div>
<div style=""><br></div><div style=""> hook before => sub { </div><div style=""> return pass if request->path !~ //;</div><div style=""> ...</div><div style=""> };</div><div style=""> </div></div></div></div>
<div>_______________________________________________</div><div>dancer-users mailing list</div><div>dancer-users@dancer.pm</div><div>http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</div></div></div>
</blockquote>
<div>
<br>
</div>