I am new to mod_perl.  I am trying to test the PerlAccessHandler using the
Apache::GateKeeper package.  However I am having trouble with the
dir_config() method.  When I access the URL I get an error 500 and the
apache log shows:

Can't locate object method "dir_config" via package "Apache2::RequestRec"
at /usr/local/apache2/mod_perl/Auth/GateKeeper.pm line 16.\n

If I modify the package and run it as a PerlResponseHandler it reads the
variable from the httpd.conf without error.

Hopefully someone can point me in the right direction.

thanks,
John

Here is the package:

package Auth::GateKeeper;

use strict;
use warnings;

use Apache2::Connection ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();

use Apache2::Const -compile => qw(FORBIDDEN OK DECLINED SERVER_ERROR);

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

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

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

1;

And the relevant portion of the httpd.conf:

<Directory "/usr/local/apache2/htdocs/authtest">
      SetHandler perl-script
      PerlAccessHandler  Auth::GateKeeper
      PerlSetVar Gate closed
      Options Indexes FollowSymLinks ExecCGI
</Directory>

Reply via email to