package Apache::GateKeeper;

use strict;
use Apache::Constants qw(:common);

sub handler {
    my $r = shift;
    my $gate = $r->dir_config("Gate");
    return DECLINED unless defined $gate;
    return OK if lc $gate eq 'open';

    if (lc $gate eq 'closed') {
        $r->log_reason("Access forbidden unless the gate is open", $r->filename);
        return FORBIDDEN;
    }

    $r->log_error($r->uri, ": Invalid value for Gate ($gate)");
    return SERVER_ERROR;
}

1;
__END__
