http://qs321.pair.com?node_id=11125637


in reply to Dancer2 hooks and perl modules

You need to package your module as a plugin to write your own hooks. See Hooks in the Dancer2::Plugin docs for more information.

More simply, if you just want to add code in the before hook of each app, write the code in a subroutine in a module, use that module in both apps, then call the sub from the before hook of each app.

Also, if you create a module with the name package A;, use Dancer2; is sufficient. Save yourself a few characters and don't be redundant with use Dancer2 appname =>'A'; And, that's one less thing to maintain if you ever rename that module.

Cheers!