开发者

Perl Dancer after hook

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

I tried with an after hook but it seems that it doesn't execute after a file request... There is a hook called 'after_file_render' which is executed 开发者_JS百科a decent number of times after each request but I am not sure what is its purpose. Is it always called after every request?


The after_file_render hook is run after each successful request for a static file (e.g., a CSS file or an image), while the after hook runs after an action is performed by a route handler.

If you want to run the same code for both after and after_file_render, you can put it in a subroutine and assign it to the two hooks using a reference, e.g.:

sub foo {
    ...
}

hook after_file_render => \&foo;
hook after => \&foo;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜