| Apache2::ASP::Base - Base class for ASP engines |
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) = @_; my $stack = Devel::StackTrace->new; warn $stack->as_string; $s->response->Clear(); $s->global_asa->can('Script_OnError')->( $stack ); 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 the Apache2::RequestRec manpage 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 the Apache2::ASP::Config manpage object.
Returns the the Apache2::RequestRec manpage object.
Returns the the Apache2::ASP::CGI manpage object.
Returns the current the Apache2::ASP::SessionStateManager manpage object.
Returns the current the Apache2::ASP::Request manpage object.
Returns the current the Apache2::ASP::Response manpage object.
Returns the current the Apache2::ASP::Server manpage object.
Returns the current the Apache2::ASP::Application manpage object.
Returns the the Apache2::ASP::GlobalASA manpage object.
Returns the classname of the the Apache2::ASP::Handler manpage 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 to submit bug reports.
Please visit the Apache2::ASP homepage at http://apache2-asp.no-ip.org/ 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.
| Apache2::ASP::Base - Base class for ASP engines |