changed the way test dumping a request works
[catagits/Catalyst-Runtime.git] / t / lib / TestFromPSGI.pm
diff --git a/t/lib/TestFromPSGI.pm b/t/lib/TestFromPSGI.pm
new file mode 100644 (file)
index 0000000..9b16aec
--- /dev/null
@@ -0,0 +1,38 @@
+package TestFromPSGI;
+
+use Moose;
+use Plack::Middleware::Static;
+use Plack::App::File;
+use Catalyst;
+
+extends 'Catalyst';
+
+my $static = Plack::Middleware::Static->new(
+  path => qr{^/static/}, root => TestMiddleware->path_to('share'));
+
+__PACKAGE__->config(
+  'Controller::Root', { namespace => '' },
+  'psgi_middleware', [
+    'Head',
+    $static,
+    'Static', { path => qr{^/static2/}, root => TestMiddleware->path_to('share') },
+    'Runtime',
+    '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddleware->path_to('share') },
+    sub {
+      my $app = shift;
+      return sub {
+        my $env = shift;
+        if($env->{PATH_INFO} =~m/forced/) {
+          Plack::App::File->new(file=>TestMiddleware->path_to(qw/share static forced.txt/))
+            ->call($env);
+        } else {
+          return $app->($env);
+        }
+      },
+    },
+
+  ],
+);
+
+__PACKAGE__->setup;
+