[Dancer-users] What's my route handler?

David Cantrell david at cantrell.org.uk
Wed Feb 15 23:53:06 CET 2012

On Wed, Feb 15, 2012 at 06:35:50PM +0000, David Precious wrote:
> David Cantrell <david at cantrell.org.uk> wrote:
> > get '/billing' => sub :CapoFamiglia :Accountants { ... };
> > get '/killing' => sub :CapoFamiglia :Hitmen      { ... };
> > 
> > So, my question is ... how can I get at those subroutine references
> > from inside my 'before' hook so that I can
> > attributes::get($route_handler) ?
> Probably the easiest, and most sane, way, would be for the before hook
> to get passed the route handler as a parameter.

While we're at it, could we also have the route - eg /killing/:client -
as well as the handler?

However, once we start passing more than one parameter around, it's
probably best to pass them as a single object so maybe decorate
Dancer::Request with them, given that request() is already available in
'before' hooks.

That would also get rid of the little niggle I would have about
specifically passing extra data to 'before' hooks - unless you meant to
also pass the data to other hooks too.

> I'll check none of the other core devs object to this (I can't think
> why they would), then Make It So. 


David Cantrell | Official London Perl Mongers Bad Influence

What profiteth a man, if he win a flame war, yet lose his cool?

More information about the Dancer-users mailing list