Created
July 16, 2010 14:44
-
-
Save jjn1056/478439 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In my Catalyst.pm: | |
if ($ENV{MOD_PERL}) { | |
use Catalyst::Engine::Loader; | |
my $apache = Catalyst::Engine::Loader->auto; | |
# FIXME - Immutable | |
$class->meta->add_method(handler => sub { | |
my $r = shift; | |
my $app = $class->psgi_app; | |
$apache->call_app($r, $app); | |
}); | |
} | |
and here's the Catalyst::Engine::Loader code: | |
package Catalyst::Engine::Loader; | |
use Moose; | |
use Catalyst::Exception; | |
use namespace::autoclean; | |
extends 'Plack::Loader'; | |
around guess => sub { | |
my ($orig, $self) = (shift, shift); | |
my $engine = $self->$orig(@_); | |
if ($engine eq 'Standalone') { | |
if ( $ENV{MOD_PERL} ) { | |
my ( $software, $version ) = | |
$ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/; | |
$version =~ s/_//g; | |
$version =~ s/(\.[^.]+)\./$1/g; | |
if ( $software eq 'mod_perl' ) { | |
if ( $version >= 1.99922 ) { | |
$engine = 'Apache2'; | |
} | |
elsif ( $version >= 1.9901 ) { | |
Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' ); | |
$engine = 'Apache2::MP19'; | |
} | |
elsif ( $version >= 1.24 ) { | |
$engine = 'Apache1'; | |
} | |
else { | |
Catalyst::Exception->throw( message => | |
qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ ); | |
} | |
} | |
} | |
} | |
return $engine; | |
}; | |
__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment