--- /dev/null
+use Plack::Middleware::Static;
+
+my $static = Plack::Middleware::Static->new(
+ path => qr{^/static/}, root => TestMiddlewareFromConfig->path_to('share'));
+
+my $conf = +{
+ 'Controller::Root', { namespace => '' },
+ 'psgi_middleware', [
+ 'Head',
+ $static,
+ 'Static', { path => qr{^/static2/}, root => TestMiddlewareFromConfig->path_to('share') },
+ 'Runtime',
+ '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddlewareFromConfig->path_to('share') },
+ sub {
+ my $app = shift;
+ return sub {
+ my $env = shift;
+ if($env->{PATH_INFO} =~m/forced/) {
+ Plack::App::File->new(file=>TestMiddlewareFromConfig->path_to(qw/share static forced.txt/))
+ ->call($env);
+ } else {
+ return $app->($env);
+ }
+ },
+ },
+
+ ],
+};
--- /dev/null
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+use FindBin;
+use Test::More;
+use HTTP::Request::Common;
+
+BEGIN { eval { require Catalyst::Plugin::ConfigLoader; 1; } ||
+ plan skip_all => 'Need Catalyst::Plugin::ConfigLoader' }
+
+use lib "$FindBin::Bin/lib";
+use Catalyst::Test 'TestMiddlewareFromConfig';
+
+ok my($res, $c) = ctx_request('/');
+
+{
+ ok my $response = request GET $c->uri_for_action('/welcome'),
+ 'got welcome from a catalyst controller';
+
+ is $response->content, 'Welcome to Catalyst',
+ 'expected content body';
+}
+
+{
+ ok my $response = request GET $c->uri_for('/static/message.txt'),
+ 'got welcome from a catalyst controller';
+
+ like $response->content, qr'static message',
+ 'expected content body';
+}
+
+{
+ ok my $response = request GET $c->uri_for('/static2/message2.txt'),
+ 'got welcome from a catalyst controller';
+
+ like $response->content, qr'static message',
+ 'expected content body';
+}
+
+{
+ ok my $response = request GET $c->uri_for('/static3/message3.txt'),
+ 'got welcome from a catalyst controller';
+
+ like $response->content, qr'static message',
+ 'expected content body';
+}
+
+{
+ ok my $response = request GET $c->uri_for('/forced'),
+ 'got welcome from a catalyst controller';
+
+ like $response->content, qr'forced message',
+ 'expected content body';
+
+ ok $response->headers->{"x-runtime"}, "Got value for expected middleware";
+}
+
+done_testing;