lemonldap-ng/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/ApacheMP2.pm

72 lines
1.7 KiB
Perl
Raw Normal View History

2017-02-16 08:37:40 +01:00
# LLNG platform class for Apache-2/ModPerl-2
#
2019-02-04 20:58:04 +01:00
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2;
use strict;
use Lemonldap::NG::Handler::ApacheMP2::Request;
2017-02-08 23:18:52 +01:00
use Lemonldap::NG::Handler::ApacheMP2::Main;
our $VERSION = '2.0.0';
# PUBLIC METHODS
sub handler {
2017-02-09 07:24:12 +01:00
shift if ($#_);
return launch( 'run', @_ );
2017-02-09 07:24:12 +01:00
}
sub logout {
shift if ($#_);
return launch( 'unlog', @_ );
2017-02-09 07:24:12 +01:00
}
sub reload {
shift if ($#_);
return launch( 'reload', @_ );
}
2017-02-09 07:24:12 +01:00
sub status {
shift if ($#_);
return launch( 'getStatus', @_ );
2017-02-09 07:24:12 +01:00
}
# Internal method to get class to load
sub launch {
my ( $sub, $r ) = @_;
2017-03-29 07:02:56 +02:00
my $req = Lemonldap::NG::Handler::ApacheMP2::Request->new($r);
my $type = Lemonldap::NG::Handler::ApacheMP2::Main->checkType($req);
2017-03-29 07:02:56 +02:00
if ( my $t = $r->dir_config('VHOSTTYPE') ) {
$type = $t;
}
2017-02-08 23:18:52 +01:00
my $class = "Lemonldap::NG::Handler::ApacheMP2::$type";
eval "require $class";
2017-02-09 07:24:12 +01:00
die $@ if ($@);
# register the request object to the logging system
if ( ref( $class->logger ) and $class->logger->can('setRequestObj') ) {
$class->logger->setRequestObj($req);
}
2022-02-16 17:43:29 +01:00
if ( ref( $class->userLogger )
and $class->userLogger->can('setRequestObj') )
{
$class->userLogger->setRequestObj($req);
}
2017-03-29 07:17:35 +02:00
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);
}
2022-02-16 17:43:29 +01:00
if ( ref( $class->userLogger )
and $class->userLogger->can('clearRequestObj') )
{
$class->userLogger->clearRequestObj($req);
}
2017-03-29 07:17:35 +02:00
return $res;
}
1;