X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flib%2FTestMiddleware.pm;fp=t%2Flib%2FTestMiddleware.pm;h=244b9572d1985b4032474198c6c9acc9d2f9a401;hp=0000000000000000000000000000000000000000;hb=c17c004aa78ef1280963f76abff75224343d71a8;hpb=3df65a8d8fa4a41c4d0ea0560875676a4cebfc6b diff --git a/t/lib/TestMiddleware.pm b/t/lib/TestMiddleware.pm new file mode 100644 index 0000000..244b957 --- /dev/null +++ b/t/lib/TestMiddleware.pm @@ -0,0 +1,35 @@ +package TestMiddleware; + +use Plack::Middleware::Static; +use Plack::App::File; +use Catalyst; + +extends 'Catalyst'; + +my $static = Plack::Middleware::Static->new( + path => qr{^/static/}, root => TestApp->path_to('share')); + +__PACKAGE__->config( + 'Controller::Root', { namespace => '' }, + 'psgi_middleware', [ + $static, + 'Static', { path => qr{^/static2/}, root => TestApp->path_to('share') }, + '+TestApp::Custom', { path => qr{^/static3/}, root => TestApp->path_to('share') }, + sub { + my $app = shift; + return sub { + my $env = shift; + if($env->{PATH_INFO} =~m/forced/) { + Plack::App::File->new(file=>TestApp->path_to(qw/share static forced.txt/)) + ->call($env); + } else { + return $app->($env); + } + }, + }, + + ], +); + +__PACKAGE__->setup; +