File: ApacheMP2.pm

package info (click to toggle)
lemonldap-ng 2.21.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,024 kB
  • sloc: perl: 77,414; javascript: 25,284; xml: 6,473; makefile: 1,303; sh: 453; sql: 159; python: 53; php: 26
file content (69 lines) | stat: -rw-r--r-- 1,755 bytes parent folder | download | duplicates (2)
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;