Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Plack::Middleware::Sendfile;
- use strict;
- use warnings;
- use base qw( Plack::Middleware );
- use IO::File::WithPath;
- sub call {
- my $self = shift;
- my $env = shift;
- my $res = $self->app->($env);
- if ( ref $res->[2] eq 'IO::File::WithPath' ) {
- $env->{'psgix.sendfile''} = $res->[2]->path;
- }
- return $res->finalize;
- }
- 1;
Add Comment
Please, Sign In to add comment