On Mon, 19 Jun 2000, Matt Sergeant wrote:
> 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.
Yeah.. thats right.. the real one has prototypes. I should have just
cut/pasted it instead of reproducing it from memory :).
>
> > ($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:
Yes.. our production version also has this.. actually, we use Error.pm from
CPAN to catch a variety of exceptions... e.g.:
try {
$this->sevice;
} catch Error::Foo with {
# do something
} catch Error::Foo2 with {
# do something else
} otherwise {
# uncaught exception
};
But I didnt feel it was worth showing all of that in my original msg :).
Mike