1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# LLNG platform class for Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2;
use strict;
use Lemonldap::NG::Handler::ApacheMP2::Request;
use Lemonldap::NG::Handler::ApacheMP2::Main;
our $VERSION = '2.19.0';
# PUBLIC METHODS
sub handler {
shift if ($#_);
return launch( 'run', @_ );
}
sub logout {
shift if ($#_);
return launch( 'unlog', @_ );
}
sub reload {
shift if ($#_);
return launch( 'reload', @_ );
}
# Internal method to get class to load
sub launch {
my ( $sub, $r ) = @_;
my $req = Lemonldap::NG::Handler::ApacheMP2::Request->new($r);
my $type = Lemonldap::NG::Handler::ApacheMP2::Main->checkType($req);
if ( my $t = $r->dir_config('VHOSTTYPE') ) {
$type = $t;
}
my $class = "Lemonldap::NG::Handler::ApacheMP2::$type";
eval "require $class";
die $@ if ($@);
# register the request object to the logging system
if ( ref( $class->logger ) and $class->logger->can('setRequestObj') ) {
$class->logger->setRequestObj($req);
}
if ( ref( $class->userLogger )
and $class->userLogger->can('setRequestObj') )
{
$class->userLogger->setRequestObj($req);
}
$class->logger->info(
"New request $class " . $req->method . " " . $req->request_uri );
my ($res) = $class->$sub($req);
# Clear the logging system before the next request
if ( ref( $class->logger ) and $class->logger->can('clearRequestObj') ) {
$class->logger->clearRequestObj($req);
}
if ( ref( $class->userLogger )
and $class->userLogger->can('clearRequestObj') )
{
$class->userLogger->clearRequestObj($req);
}
return $res;
}
1;
|