Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Dancer 有没有办法在每次请求后执行代码?
我尝试了一个 after 钩子,但它似乎在文件请求后没有执行......有一个名为“after_file_render”的钩子在每次请求后执行了相当多的次数,但我不确定它的目的是什么. 每次请求后总是调用它吗?
钩子在after_file_render每次成功请求静态文件(例如,CSS 文件或图像)after后运行,而钩子在路由处理程序执行操作后运行。
after_file_render
after
如果你想为两者运行相同的代码afterand after_file_render,你可以把它放在一个子例程中,并使用引用将它分配给两个钩子,例如:
sub foo { ... } hook after_file_render => \&foo; hook after => \&foo;