Skip to content

Instantly share code, notes, and snippets.

@ytnobody
Created September 3, 2013 03:26
Show Gist options
  • Save ytnobody/6419435 to your computer and use it in GitHub Desktop.
Save ytnobody/6419435 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Test::More;
use Plack::Builder;
use Plack::Test;
use HTTP::Request::Common;
my $app = sub { [200,[],['Hello, World']] };
my $wrapped = builder {
enable 'SimpleContentFilter', filter => sub { s/Hello/Welcome/g; };
$app;
};
test_psgi $wrapped, sub {
my $cb = shift;
my $res = $cb->(GET '/');
ok $res->is_success;
is $res->content, 'Welcome, World';
};
done_testing;
@ytnobody
Copy link
Author

ytnobody commented Sep 3, 2013

SimpleContentFilter checks that Content-Type is 'text/*'.
When not matched, content will not be filtering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment