NAME

Konstrukt::Handler - Base class for handlers that control the processing of the requests

SYNOPSIS

        use Konstrukt::Handler;
        
        #inherit new(), process() and emergency_exit()
        use base 'Konstrukt::Handler';
        
        #create handler sub. usually a bit more comprehensive. see existing handlers
        sub handler {
                my ($self) = @_;
                print $self->process();
        }
        
        #optional: overwrite method emergency_exit to provide some more info.
        sub emergency_exit {
                my ($self) = @_;
                #do something. e.g. print out error messages.
                die;
        }

DESCRIPTION

Base class for the Konstrukt handlers.

You should inherit from this class when building your own handler.

You will find the handlers currently available in the Konstrukt::Handler directory.

Plugins and other module may access some request-specific data:

        #the absolute path to the processed file
        $Konstrukt::Handler->{abs_filename}
        
        #the path to the processed file relative to the document root
        $Konstrukt::Handler->{filename}
        
        #the environment variables of this process as an hashref
        $Konstrukt::Handler->{ENV}
        
        #cookies as an hashref of cookie objects
        $Konstrukt::Handler->{cookies}
        #create new cookie:
        $Konstrukt::Handler->{cookies}->{foo} = CGI::Cookie->new(-name => 'foo', -value => 'bar');

CONFIGURATION

Defaults:

        #put the debug and error messages at the end of the output.
        #also print these messages on a critical error.
        handler/show_debug_messages 0
        handler/show_error_messages 1
        

METHODS

new

Constructor of this class

Parameters:

  • $root - The absolute path of the document root

  • $filename - The file to process (relative to the document root)

process

Processes the request. Returns the result.

emergency_exit

Will be called on a critical error. You should clean up here, put out the error messages and abort the further processing ("die").

This method should be overwritten by the inheriting class.

AUTHOR

Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.

This document is free software. It is distributed under the same terms as Perl itself.

SEE ALSO

Konstrukt::Handler::Apache, Konstrukt::Handler::CGI, Konstrukt::Handler::File, Konstrukt