fix environment changes within subdispatch and arrange for middleware to uplevel...
[catagits/Web-Simple.git] / t / response-filter.t
CommitLineData
ca739b0d 1use strictures 1;
16c72d23 2use Test::More;
3use Plack::Test;
4use HTTP::Request::Common qw(GET POST);
5
6{
7 package t::Web::Simple::ResponseFilter;
8 use Web::Simple;
9 sub dispatch_request {
10 my $self = shift;
ca739b0d 11 sub (.html) {
16c72d23 12 response_filter {
13 return [
14 200,
15 [ 'Content-Type' => 'text/html' ],
16 [ shift->{name} ],
17 ];
1f4dd6f9 18 }
16c72d23 19 },
20 sub (GET + /index) {
21 bless {name=>'john'}, 'CrazyHotWildWet';
22 },
23 }
24}
25
26ok my $app = t::Web::Simple::ResponseFilter->new->to_psgi_app,
27 'Got a plack app';
28
29test_psgi $app, sub {
30 my $cb = shift;
31 my $res = $cb->(GET "/index.html");
32 like $res->content, qr/john/,
33 'Got Expected Content';
34};
35
36done_testing;