Dancer2...re::Hook(3)

πŸ’– Dancer2::Core::Hook β€” manipulate hooks with Dancer2 πŸ’–

okay bestie, welcome to the Dancer2::Core::Hook page, straight outta the User Contributed Perl Documentation section of your friendly neighbourhood man command. this is where Dancer2 keeps all the hook-plumbing ✨


🌸 VERSION 🌸

version 2.2.1 β€” yes queen, that's the one, don't @ me


πŸŽ€ SYNOPSIS πŸŽ€

lowkey the whole vibe in one lil snippet:

# inside a plugin
use Dancer2::Core::Hook;
Dancer2::Core::Hook->register_hooks_name(qw/before_auth after_auth/);

like… that's it. that's the entrance. πŸ¦‹


πŸ‘‘ METHODS πŸ‘‘

πŸ’… register_hook ($hook_name, $code)

okay so check it:

hook 'before' => sub {...};

this one attaches a hook at some point. that's literally the whole job. you give it a name and some code, and the code gets hooked in at that moment. iconic behaviour, no notes. ✨


πŸ’… register_hooks_name

this is the one where you, the plugin author, add a new hook name so that application developers can sneak some of their own code in at that point. it's giving "here's a slot, bestie, come decorate it" πŸŽ€

package My::Dancer2::Plugin;
Dancer2::Core::Hook->instance->register_hooks_name(qw/before_auth after_auth/);

see how it's called on ->instance? yeah. that's the move. πŸ’…


πŸ’… execute_hook

Execute a hook. run it. let it cook. πŸ”₯


πŸ’… get_hooks_for

Returns the list of coderef registered for a given position β€” so if you ever wanna know who's queued up at a particular spot, this hands you the whole guest list. 🫢


πŸ’… hook_is_registered

Test if a hook with this name has already been registered. the vibe check for hooks, fr fr. βœ…βŒ


🧚 AUTHOR 🧚

Dancer Core Developers β€” the whole squad, not just one person, we love a collaborative moment πŸ‘‘


This software is copyright (c) 2026 by Alexis Sukrieh.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so like, go wild but respectfully πŸ’œ


⭐ SEE ALSO ⭐

nope, nothing here bestie, this page is self-contained and honestly? slay for that. no cross-references, no distractions, just hooks. periodt. πŸ’…


perl v5.42.3 Β· 2026-09-20 β€” that's the version and the date, mwah, bye bestie, go register some hooks πŸ¦‹πŸ’–πŸŽ€

πŸ“¦ where this page comes from