fixed running unnder http server test failure and added some pod
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / Loader.pm
1 package Catalyst::Engine::Loader;
2 use Moose;
3 use Catalyst::Exception;
4 use namespace::autoclean;
5
6 extends 'Plack::Loader';
7
8 around guess => sub {
9     my ($orig, $self) = (shift, shift);
10     my $engine = $self->$orig(@_);
11     if ($engine eq 'Standalone') {
12         if ( $ENV{MOD_PERL} ) {
13             my ( $software, $version ) =
14                 $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/;
15
16             $version =~ s/_//g;
17             if ( $software eq 'mod_perl' ) {
18                 if ( $version >= 1.99922 ) {
19                     $engine = 'Apache2';
20                 }
21
22                 elsif ( $version >= 1.9901 ) {
23                     Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' );
24                     $engine = 'Apache2::MP19';
25                 }
26
27                 elsif ( $version >= 1.24 ) {
28                     $engine = 'Apache1';
29                 }
30
31                 else {
32                     Catalyst::Exception->throw( message =>
33                           qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ );
34                 }
35             }
36         }
37     }
38     return $engine;
39 };
40
41 __PACKAGE__->meta->make_immutable( inline_constructor => 0 );
42
43 1;
44
45 __END__
46
47 =head1 NAME
48
49 Catalyst::Engine::Loader - The Catalyst Engine Loader
50
51 =head1 SYNOPSIS
52
53 See L<Catalyst>.
54
55 =head1 DESCRIPTION
56
57 Wrapper on L<Plack::Loader> which resets the ::Engine if you are using some
58 version of mod_perl.
59
60 =head1 AUTHORS
61
62 Catalyst Contributors, see Catalyst.pm
63
64 =head1 COPYRIGHT
65
66 This library is free software. You can redistribute it and/or modify it under
67 the same terms as Perl itself.
68
69 =cut