You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by James G Smith <JG...@TAMU.Edu> on 2002/01/03 18:21:00 UTC

RFC: Apache::Handlers

This is a module I am working on, but haven't debugged yet.  Looking
for comments on what the name of the module should be if
Apache::Handlers is not a good name.  General comments on design are
welcome as well.


NAME
     Apache::Handlers

SYNOPSIS
     In code:

       use Apache::Handlers qw(CLEANUP PerlCleanupHandler);

       our $global;
       our $other_global : PerlCleanupHandler;
       my  $lexical : PerlLogHandler(sub { print STDERR "$lexical\n"; });

       CLEANUP {
         our $global = undef;
       };

     In httpd.conf:

       PerlModule Apache::Handlers
       PerlChildInitHandler Apache::Handlers

DESCRIPTION
     "Apache::Handlers" provides two different methods of
     declaring when code snippets should be run during the Apache
     request phase.

     If "Attribute::Handlers" is available, then attributes are
     defined that allow cleanup or setting of values during
     particular request phases.

     The code defined with the constructs provided by this module do
     not directly affect the success or failure of the request.
     Thus, this module does not provide a replacement for content,
     access, or other handlers.

BLOCK CONSTRUCTS
     The following allow for blocks of code to be run at the
     specified phase.  Note that these are subroutines taking a
     single code reference argument and thus require a
     terminating semi-colon (;).  They are named to be like the
     BEGIN, END, etc., constructs in Perl, though they are not
     quite at the same level in the language.

     If the code is seen and handled before Apache has handled a
     request, it will be run for each request.  Otherwise, it is
     pushed on the handler stack, run, and then removed at the
     end of the request.

     ACCESS
     AUTHEN
     AUTHZ
     CHILDEXIT
     CHILDINIT
     CLEANUP
     CONTENT
     FIXUP
     HEADERPARSER
     LOG
     POSTREADREQUEST
     TRANS
     TYPE

ATTRIBUTES
     If Attribute::Handlers is available, then the following
     attributes are available.

     If the attribute argument is a constant value (non-CODE
     reference), then the variable is assigned that value.
     Otherwise, the CODE is run and the return value is assigned
     to the variable.

     PerlAccessHandler
     PerlAuthenHandler
     PerlAuthzHandler
     PerlChildInitHandler
     PerlChildExitHandler
     PerlCleanupHandler
     PerlFixupHandler
     PerlHandler
     PerlHeaderParserHandler
     PerlLogHandler
     PerlPostReadRequestHandler
     PerlTransHandler
     PerlTypeHandler


--
James Smith <JG...@TAMU.Edu>, 979-862-3725
Texas A&M CIS Operating Systems Group, Unix

Re: RFC: Apache::Handlers

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> 
>        use Apache::Handlers qw(CLEANUP PerlCleanupHandler);
> 
>        our $global;
>        our $other_global : PerlCleanupHandler;
>        my  $lexical : PerlLogHandler(sub { print STDERR "$lexical\n"; });
> 
>        CLEANUP {
>          our $global = undef;
>        };

heh, seems like you should do this if only for the fun of it - nifty
idea.

sub printstuff : PerlHandler {...};

might be a neat piece of magic.

--Geoff