before/after hooks?

11 views
Skip to first unread message

Brian

unread,
Oct 26, 2016, 6:37:35 PM10/26/16
to Perl Kelp
Do you have a suggestion for running some code before each request handling method is called?  For example, if I have a route like $r->add('/home/', 'home'); I want some code to run before my home() method is called.  I want this to happen for every request.  I need it in the context of a request so there will be a request object and session hash and such available.  In CGI::Application there is cgiapp_prerun() and cgiapp_postrun() to do this.  In Dancer there are before/after hooks.

Thank you,
Brian

Stefan Geneshky

unread,
Oct 26, 2016, 6:48:48 PM10/26/16
to perl...@googlegroups.com
You can do that either by using a bridge, see https://metacpan.org/pod/Kelp::Routes#BRIDGES or by creating your own request subclass, see https://metacpan.org/pod/Kelp#build_request .

Stefan
Reply all
Reply to author
Forward
0 new messages