Commit | Line | Data |
c17c004a |
1 | package TestMiddleware; |
2 | |
10e39267 |
3 | use Moose; |
c17c004a |
4 | use Plack::Middleware::Static; |
5 | use Plack::App::File; |
6 | use Catalyst; |
7 | |
8 | extends 'Catalyst'; |
9 | |
10 | my $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 | |