Created
November 12, 2012 02:42
-
-
Save leedo/4057223 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
use Plack::Builder; | |
use Plack::App::Proxy; | |
builder { | |
enable sub { | |
my $app = shift; | |
sub { | |
my $env = shift; | |
delete $env->{HTTP_ACCEPT_ENCODING}; | |
my $res = $app->($env); | |
Plack::Util::response_cb($res, sub { | |
my $res = shift; | |
my $headers = Plack::Util::headers($res->[1]); | |
if ($headers->get("Content-Type") =~ /html/i) { | |
return sub { | |
my $chunk = shift; | |
return unless defined $chunk; | |
$chunk =~ s/Top Story/Super Top Story/g; | |
return $chunk; | |
}; | |
} | |
}); | |
}; | |
}; | |
mount "/" => Plack::App::Proxy->new(remote => "http://arstechnica.com/")->to_app; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment