manifest_include 't/conf' => 'extra.conf.in';
manifest_include 't/lib/TestContentNegotiation/share', 'file.txt';
manifest_include 't/lib/TestMiddleware/share' => qr/.*/;
-manifest_include 't/lib/TestMiddlewareFromConfig/share' => qr/.*/;
-manifest_include 't/lib/TestMiddlewareFromConfig' => 'testmiddlewarefromconfig.pl';
+manifest_include 't/lib/TestMiddlewareFromPlugin/share' => qr/.*/;
+manifest_include 't/lib/TestMiddlewareFromPlugin' => 'testmiddlewarefromplugin.pl';
manifest_include t => qr/optional_apache-.*\.pl/;
manifest_include t => 'optional_stress.json';
manifest_include t => 'something/Makefile.PL';
-package TestMiddlewareFromConfig;
+package TestMiddlewareFromPlugin;
-use Catalyst qw/ConfigLoader/;
+use Catalyst qw/+TestMiddlewareFromPlugin::SetMiddleware/;
## Proof this is good config
-##__PACKAGE__->config( do TestMiddlewareFromConfig->path_to('testmiddlewarefromconfig.pl') );
+##__PACKAGE__->config( do TestMiddlewareFromConfig->path_to('testmiddlewarefromplugin.pl') );
__PACKAGE__->setup_middleware('Head');
__PACKAGE__->setup;
+1;
-package TestMiddlewareFromConfig::Controller::Root;
+package TestMiddlewareFromPlugin::Controller::Root;
use Moose;
use MooseX::MethodAttributes;
-package TestMiddlewareFromConfig::Custom;
+package TestMiddlewareFromPlugin::Custom;
use strict;
use warnings;
--- /dev/null
+package TestMiddlewareFromPlugin::SetMiddleware;
+use strict;
+use warnings;
+use File::Spec;
+use File::Basename ();
+
+my $config_path = File::Spec->catfile(File::Basename::dirname(__FILE__), 'testmiddlewarefromplugin.pl');
+
+sub setup {
+ my $c = shift;
+ $c->config(do $config_path);
+ $c->next::method(@_);
+}
+
+1;
use Plack::Middleware::Static;
my $static = Plack::Middleware::Static->new(
- path => qr{^/static/}, root => TestMiddlewareFromConfig->path_to('share'));
+ path => qr{^/static/}, root => TestMiddlewareFromPlugin->path_to('share'));
my $conf = +{
'Controller::Root', { namespace => '' },
'psgi_middleware', [
$static,
- 'Static', { path => qr{^/static2/}, root => TestMiddlewareFromConfig->path_to('share') },
+ 'Static', { path => qr{^/static2/}, root => TestMiddlewareFromPlugin->path_to('share') },
'Runtime',
- '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddlewareFromConfig->path_to('share') },
+ '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddlewareFromPlugin->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/))
+ Plack::App::File->new(file=>TestMiddlewareFromPlugin->path_to(qw/share static forced.txt/))
->call($env);
} else {
return $app->($env);
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';
+use Catalyst::Test 'TestMiddlewareFromPlugin';
ok my($res, $c) = ctx_request('/');