Commit | Line | Data |
532f0516 |
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 ) = |
d7132282 |
14 | $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/; |
532f0516 |
15 | $version =~ s/_//g; |
d7132282 |
16 | $version =~ s/(\.[^.]+)\./$1/g; |
17 | |
532f0516 |
18 | if ( $software eq 'mod_perl' ) { |
19 | if ( $version >= 1.99922 ) { |
20 | $engine = 'Apache2'; |
21 | } |
22 | |
23 | elsif ( $version >= 1.9901 ) { |
24 | Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' ); |
25 | $engine = 'Apache2::MP19'; |
26 | } |
27 | |
28 | elsif ( $version >= 1.24 ) { |
29 | $engine = 'Apache1'; |
30 | } |
31 | |
32 | else { |
33 | Catalyst::Exception->throw( message => |
34 | qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ ); |
35 | } |
36 | } |
37 | } |
38 | } |
d7132282 |
39 | |
532f0516 |
40 | return $engine; |
41 | }; |
42 | |
43 | __PACKAGE__->meta->make_immutable( inline_constructor => 0 ); |
df1fa879 |
44 | |
532f0516 |
45 | 1; |
df1fa879 |
46 | |
47 | __END__ |
48 | |
49 | =head1 NAME |
50 | |
51 | Catalyst::Engine::Loader - The Catalyst Engine Loader |
52 | |
53 | =head1 SYNOPSIS |
54 | |
55 | See L<Catalyst>. |
56 | |
57 | =head1 DESCRIPTION |
58 | |
59 | Wrapper on L<Plack::Loader> which resets the ::Engine if you are using some |
60 | version of mod_perl. |
61 | |
62 | =head1 AUTHORS |
63 | |
64 | Catalyst Contributors, see Catalyst.pm |
65 | |
66 | =head1 COPYRIGHT |
67 | |
68 | This library is free software. You can redistribute it and/or modify it under |
69 | the same terms as Perl itself. |
70 | |
71 | =cut |