[Dancer-users] Selectively calling before() from route handlers
Gurunandan Bhat
gbhat at pobox.com
Fri Dec 17 14:44:12 CET 2010
On Fri, Dec 17, 2010 at 5:09 PM, David Precious <davidp at preshweb.co.uk>wrote:
> On Friday 17 December 2010 06:31:33 Gurunandan Bhat wrote:
> > Hi,
> >
> > Is there a way I can set whether a particular route handler calls
> before().
> > I am looking to implement authenticated/unauthenticated routes and would
> > like to execute before() only if the route requires authentication. Any
> > suggestions in doing something like this would be great.
>
>
> before handlers are called before all requests, but you don't have to do
> anything if the request isn't one you're interested in.
>
> e.g.
>
> before sub {
> return if request->path_info !~ m{^/private/};
> # Authentication stuff here
> };
> Is that any use?
>
Yes, in effect, currently this is how I am doing it. What I have done now is
to put the yaml config which I search in before() to check if I need to run
at all.
> Of course, that means the list of which routes require authentication is
> kept
> separately to the route declarations themselves, which might not be what
> you
> want.
>
>
Indeed. Thats what I am looking for: Ideally some syntactic sugar that I
sweeten my route handler with:
*run before => true;*
Dancer does spoil you, doesn't it :)
Thank you.
>
>
> Cheers
>
> Dave P
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20101217/fa028b12/attachment.htm>
More information about the Dancer-users
mailing list