
Apache2::ASP::Base - Base class for ASP engines

package MyASP;
use strict;
use base 'Apache2::ASP::Base';
# Use whatever Apache2::* and APR::* modules are necessary:
sub handler : method
{
my ($class, $r) = @_;
# We function best as an object:
my $s = $class->SUPER::new( $ENV{APACHE2_ASP_CONFIG} );
# What Apache2::ASP::Handler is going to handle this request?
my $handler_class = $s->resolve_request_handler( $r->uri );
if( $handler_class->isa('Apache2::ASP::UploadHandler') )
{
# We use the upload_hook functionality from Apache::Request
# to process uploads:
my $upload_hook = sub {
my ($upload, $data) = @_;
# Handle upload hook here...
};
$s->{q} = Apache2::ASP::CGI->new( $r, $upload_hook );
}
else
{
# Not an upload - normal CGI functionality will work fine:
$s->{q} = Apache2::ASP::CGI->new( $r );
}# end if()
# Get our subref and execute it:
my $handler = $s->setup_request( $r, $s->{q} );
my $status = eval { $handler->( ) };
if( $@ )
{
warn "ERROR AFTER CALLING \$handler->( ): $@";
return $s->_handle_error( $@ );
}# end if()
# 0 = OK, everything else means errors of some kind:
return $status;
}# end handler()
sub _handle_error
{
my ($s, $err) = @_;
war $err;
$s->response->Clear();
$s->global_asa->can('Script_OnError')->( $err );
return 500;
}# end _handle_error()


Returns a new Apache2::ASP::Base object using the Apache2::ASP::Config object passed in as $config.
Creates a new request instance, based on the information about the request gleaned from $r - an Apache2::RequestRec object (or something that behaves like one anyway).
Returns a subroutine reference.
Execute like:
my $ref = $asp->setup_request( $r ); # A normal request: $ref->( 0 ); # or $ref->( ); # A subrequest (i.e. as in the case of an include): $ref->( 1 );
Returns the current Apache2::ASP::Config object.
Returns the Apache2::RequestRec object.
Returns the Apache2::ASP::CGI object.
Returns the current Apache2::ASP::SessionStateManager object.
Returns the current Apache2::ASP::Request object.
Returns the current Apache2::ASP::Response object.
Returns the current Apache2::ASP::Server object.
Returns the current Apache2::ASP::Application object.
Returns the Apache2::ASP::GlobalASA object.
Returns the classname of the Apache2::ASP::Handler subclass that will process the current HTTP request.

It's possible that some bugs have found their way into this release.
Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP to submit bug reports.

Please visit the Apache2::ASP homepage at http://www.devstack.com/ to see examples of Apache2::ASP in action.

John Drago mailto:jdrago_999@yahoo.com

Copyright 2007 John Drago, All rights reserved.
This software is free software. It may be used and distributed under the same terms as Perl itself.