On Fri, Dec 17, 2010 at 5:09 PM, David Precious
<davidp@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@perldancer.org
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users