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