Perl Dancer after the hook

Is there a way in Dancer to execute code after each request?

I tried with a hook, but it seems that it does not execute after a file request ... There is a hook called "after_file_render" that runs several times after each request, but I'm not sure what its purpose is. Is it always called after every request?

+6
source share
1 answer

The after_file_render capture after_file_render triggered after each successful request for a static file (for example, a CSS file or image), and the after hook is triggered after the action is executed by the route handler.

If you want to run the same code for after and after_file_render , you can put it in a subroutine and assign it to two hooks using a link, for example:

 sub foo { ... } hook after_file_render => \&foo; hook after => \&foo; 
+9
source

Source: https://habr.com/ru/post/898265/


All Articles