Created
October 3, 2009 20:03
-
-
Save nihen/200835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment