Skip to content

Instantly share code, notes, and snippets.

@nihen
Created October 3, 2009 20:03
Show Gist options
  • Save nihen/200835 to your computer and use it in GitHub Desktop.
Save nihen/200835 to your computer and use it in GitHub Desktop.
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