Guest User

Untitled

a guest
Mar 13th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  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;
Add Comment
Please, Sign In to add comment