Skip to content

Instantly share code, notes, and snippets.

@leedo
Created November 12, 2012 02:42
Show Gist options
  • Save leedo/4057223 to your computer and use it in GitHub Desktop.
Save leedo/4057223 to your computer and use it in GitHub Desktop.
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