资源说明:Enables CSS Refreshing without Reloading Whole Page
package Plack::Middleware::AutoReloadCSS;
use 5.008;
use strict;
use warnings;
use Plack::Util ();
use Plack::Util::Accessor qw(interval);
use parent qw(Plack::Middleware);
our $VERSION = '0.02';
sub call {
my($self, $env) = @_;
$self->response_cb($self->app->($env), sub {
my $res = shift;
my $content_type = Plack::Util::header_get($res->[1], 'Content-Type');
if (!Plack::Util::status_with_no_entity_body($res->[0]) &&
(($content_type || '') =~ m{^(?:text/html|application/xhtml\+xml)})) {
return sub {
my $chunk = shift;
return if !defined $chunk;
$chunk =~ s{