Created
December 20, 2009 18:09
-
-
Save nihen/260590 to your computer and use it in GitHub Desktop.
This file contains hidden or 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::LastModified; | |
use strict; | |
use parent qw( Plack::Middleware ); | |
use Plack::Util; | |
use File::stat; | |
use HTTP::Date; | |
sub call { | |
my $self = shift; | |
my $env = shift; | |
my $res = $self->app->($env); | |
$self->response_cb($res, sub { | |
my $res = shift; | |
return unless Plack::Util::is_real_fh($res->[2]); | |
Plack::Util::header_set($res->[1], 'Last-Modified' => HTTP::Date::time2str( stat($res->[2])->mtime )); | |
}); | |
} | |
1; | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment