[dancer-users] Dancer2 before_file_render hook

Andrew Beverley andy at andybev.com
Sun Sep 27 17:17:49 BST 2015


On Sun, 2015-09-27 at 18:06 +0200, Alex Mestiashvili wrote:
> Is there a way to protect a file in the public directory with Dancer2?

I think the answer is probably "don't put it in the public area".

If it's not for public consumption, I suggest you use send_file in a route
instead.

> In Dancer I was using before_file_render hook to achieve that.
> before_file_render is still present in Dancer2::Handler::File, but It
> doesn't work out of box for me.

Because it is assumed that anything in the public area is exactly that, the
files are sent as quickly as possible, without wasting time in hooks etc.

I think there was some info on these changes in the Perl Advent Calendar.

Andy




More information about the dancer-users mailing list