first go at upgrading docs
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / Loader.pm
CommitLineData
532f0516 1package Catalyst::Engine::Loader;
2use Moose;
3use Catalyst::Exception;
4use namespace::autoclean;
5
6extends 'Plack::Loader';
7
8around 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 451;
df1fa879 46
47__END__
48
49=head1 NAME
50
51Catalyst::Engine::Loader - The Catalyst Engine Loader
52
53=head1 SYNOPSIS
54
55See L<Catalyst>.
56
57=head1 DESCRIPTION
58
59Wrapper on L<Plack::Loader> which resets the ::Engine if you are using some
60version of mod_perl.
61
62=head1 AUTHORS
63
64Catalyst Contributors, see Catalyst.pm
65
66=head1 COPYRIGHT
67
68This library is free software. You can redistribute it and/or modify it under
69the same terms as Perl itself.
70
71=cut