# MASON Configuration for netdisco 
#   This file applied to the global server space.
# $Id$

LoadModule perl_module  libexec/apache2/mod_perl.so
LoadModule apreq_module libexec/apache2/mod_apreq2.so
PerlModule CGI
PerlModule Apache2::compat
PerlModule Apache2::Request

# Pool Database Connections
PerlModule Apache::DBI

<Directory /usr/pkg/netdisco/html>
	# Apache <= 2.2
	#order allow,deny
	#allow from all

	# Apache >= 2.4
	Require all granted
</Directory>

<Perl>
# Preload the netdisco module into global server space.
#   and parse the config file only once.
{ package HTML::Mason::Commands;
    use lib '/usr/pkg/netdisco';
    use netdisco qw/:all/;
    &netdisco::config('/usr/pkg/netdisco/netdisco.conf');
}

# Setup Mason and Session Handler
{ package netdisco::Mason; 
    use HTML::Mason;
    use HTML::Mason::ApacheHandler;
    use strict;

    my $ah = new HTML::Mason::ApacheHandler(
        args_method            => 'mod_perl',
        comp_root              => '/usr/pkg/netdisco/html',
        data_dir               => '/usr/pkg/netdisco/mason',
        request_class          => 'MasonX::Request::WithApacheSession',
        session_class          => 'Apache::Session::Postgres',
        session_commit         => 1,
        session_use_cookie     => 1,
        session_cookie_expires => '+1y',
        session_cookie_name    => 'netdisco',
#!! Change the following lines to match your Database Configuration.
        session_data_source    => 'dbi:Pg:dbname=netdisco',
        session_user_name      => 'netdisco',
        session_password       => 'PASSWORDHERE',
                                           );
    sub handler {
        my $request = shift;
        return $ah->handle_request($request);
    }
}
</Perl>
