first pass at middleware tests
[catagits/Catalyst-Runtime.git] / t / lib / TestMiddleware.pm
CommitLineData
c17c004a 1package TestMiddleware;
2
3use Plack::Middleware::Static;
4use Plack::App::File;
5use Catalyst;
6
7extends 'Catalyst';
8
9my $static = Plack::Middleware::Static->new(
10 path => qr{^/static/}, root => TestApp->path_to('share'));
11
12__PACKAGE__->config(
13 'Controller::Root', { namespace => '' },
14 'psgi_middleware', [
15 $static,
16 'Static', { path => qr{^/static2/}, root => TestApp->path_to('share') },
17 '+TestApp::Custom', { path => qr{^/static3/}, root => TestApp->path_to('share') },
18 sub {
19 my $app = shift;
20 return sub {
21 my $env = shift;
22 if($env->{PATH_INFO} =~m/forced/) {
23 Plack::App::File->new(file=>TestApp->path_to(qw/share static forced.txt/))
24 ->call($env);
25 } else {
26 return $app->($env);
27 }
28 },
29 },
30
31 ],
32);
33
34__PACKAGE__->setup;
35