1 package Catalyst::EngineLoader;
3 use Catalyst::Exception;
5 use namespace::autoclean;
7 extends 'Plack::Loader';
9 has application_name => (
15 has requested_engine => (
18 predicate => 'has_requested_engine',
21 sub needs_psgi_engine_compat_hack {
23 return $self->has_requested_engine
24 && $self->requested_engine eq 'PSGI';
27 has catalyst_engine_class => (
31 builder => '_guess_catalyst_engine_class',
34 sub _guess_catalyst_engine_class {
36 my $old_engine = $self->has_requested_engine
37 ? $self->requested_engine
38 : Catalyst::Utils::env_value($self->application_name, 'ENGINE');
39 if (!defined $old_engine) {
40 return 'Catalyst::Engine';
42 elsif ($old_engine =~ /^(PSGI|CGI|FastCGI|HTTP|Apache.*)$/) {
43 return 'Catalyst::Engine';
46 return 'Catalyst::Engine::' . $old_engine;
51 my ($orig, $self) = (shift, shift);
52 my $engine = $self->$orig(@_);
53 if ($engine eq 'Standalone') {
54 if ( $ENV{MOD_PERL} ) {
55 my ( $software, $version ) =
56 $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/;
58 $version =~ s/(\.[^.]+)\./$1/g;
60 if ( $software eq 'mod_perl' ) {
61 if ( $version >= 1.99922 ) {
65 elsif ( $version >= 1.9901 ) {
66 Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' );
67 $engine = 'Apache2::MP19';
70 elsif ( $version >= 1.24 ) {
75 Catalyst::Exception->throw( message =>
76 qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ );
82 my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
83 if (!defined $old_engine) { # Not overridden
85 elsif ($old_engine =~ /^(PSGI|CGI|HTTP|Apache.*)$/) {
88 elsif ($old_engine eq 'FastCGI') {
91 elsif ($old_engine eq "HTTP::Prefork") { # Too bad if you're customising, we don't handle options
92 # write yourself a script to collect and pass in the options
95 elsif ($old_engine eq "HTTP::POE") {
96 Catalyst::Exception->throw("HTTP::POE engine no longer works, recommend you use Twiggy instead");
98 elsif ($old_engine eq "Zeus") {
99 Catalyst::Exception->throw("Zeus engine no longer works");
102 warn("You asked for an unrecognised engine '$old_engine' which is no longer supported, this has been ignored.\n");
108 # Force constructor inlining
109 __PACKAGE__->meta->make_immutable( replace_constructor => 1 );
117 Catalyst::EngineLoader - The Catalyst Engine Loader
125 Wrapper on L<Plack::Loader> which resets the ::Engine if you are using some
130 Catalyst Contributors, see Catalyst.pm
134 This library is free software. You can redistribute it and/or modify it under
135 the same terms as Perl itself.
139 needs_psgi_engine_compat_hack