On Sun, 18 Jun 2000, Michael J Schout wrote:
> On Tue, 13 Jun 2000, Erich L. Markert wrote:
>
> > I'm trying to figure out the best way to make apps (un)available without
> > having to edit the apache config files.
>
> We did something like this by making a handler like this:
>
> package Foo::PerlHandler;
>
> use Class::MethodMaker
> new_with_init => 'new',
> get_set => [qw/request/];
>
> sub handler {
> my ($class, $r) = @_;
You forgot prototypes here, otherwise handler always gets called with just
$r.
> ($class, $r) = (__PACKAGE__, $class) unless defined $r;
>
> if (-f /tmp/foo.unavailable) {
> $r->headers_out->add('Location', '/maintenance/index.html');
> return REDIRECT;
> }
>
> my $this = $class->new($r);
> $this->service;
You've also forgotten your exception handling code here. Always try and
wrap your dispatch code in an eval:
eval { $this->service; };
if ($@) {
# catch exceptions
}
--
<Matt/>
Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org