daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Plack::Middleware::Sendfile;
  2. use strict;
  3. use warnings;
  4. use base qw( Plack::Middleware );
  5.  
  6. use IO::File::WithPath;
  7.  
  8. sub call {
  9.     my $self = shift;
  10.     my $env  = shift;
  11.  
  12.     my $res = $self->app->($env);
  13.  
  14.     if ( ref $res->[2] eq 'IO::File::WithPath' ) {
  15.         $env->{'psgix.sendfile''} = $res->[2]->path;
  16.     }
  17.  
  18.     return $res->finalize;
  19. }
  20.  
  21. 1;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top