[Dancer-users] Plugin hooks and prefix

Ovid curtis_ovid_poe at yahoo.com
Fri Mar 23 16:39:58 CET 2012


----- Original Message -----

> From: Alexis Sukrieh <sukria at sukria.net>


> I'll do it that way:
> 
> In the plugin:
> 
> register 'before_hook_for_prefix' => sub {
>    my ($prefix) = @_;
> 
>    hook 'before' => sub {
>        if (request->path =~ /^$prefix/) {
>            ....
>        }
>    };
> };
> 
> And in the app:
> 
> use MyPlugin;
> 
> before_hook_for_prefix '/companies';
> 
> See the idea?
> 
> Of course, that's one way, there must be many others.


Works like a charm and tests pass with flying colors. Thanks!
 
Cheers,
Ovid
--
Live and work overseas - http://overseas-exile.blogspot.com/
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://blogs.perl.org/users/ovid/
Twitter - http://twitter.com/OvidPerl/



More information about the Dancer-users mailing list