Apache-Wombat
view release on metacpan or search on metacpan
lib/Apache/Wombat/Connector.pm view on Meta::CPAN
# -*- Mode: Perl; indent-tabs-mode: nil; -*-
package Apache::Wombat::Connector;
=pod
=head1 NAME
Apache::Wombat::Connector - Apache/mod_perl connector
=head1 SYNOPSIS
# My/Handler.pm
my $connector = Apache::Wombat::Connector->new();
$connector->setName('Apache connector');
$connector->setScheme('http');
$connector->setSecure(undef)
# ... create a Service as $service
# calls $connector->setContainer() internally
$service->addConnector($connector);
sub child_init_handler {
my $r = shift;
$connector->start();
return Apache::Constants::OK;
}
sub handler {
my $r = shift;
$connector->process($r);
return $r->status();
}
sub child_exit_handler {
my $r = shift;
$connector->stop();
return Apache::Constants::OK;
}
# httpd.conf:
<Location />
SetHandler perl-script
PerlChildInitHandler My::Handler::child_init_handler
PerlHandler My::Handler::handler
PerlChildExitHandler My::Handler::child_exit_handler
</Location>
=head1 DESCRIPTION
This Connector receives requests from and returns responses to an
Apache web server within which Wombat is embedded. It does not listen
on a socket but rather provides a C<process()> entry point with which
it receives and returns an B<Apache> instance. It provides HttpRequest
and HttpResponse implementations that delegate many fields and methods
to an underlying B<Apache::Request> instance.
ApacheConnector assumes an Apache 1 & mod_perl 1 single-threaded
multi-process environment. It's unknown whether it will work in any
other environment.
Requires mod_perl to be compiled with at least one of the following
options:
DYNAMIC=1
PERL_TABLE_API=1
EVERYTHING=1
=cut
use base qw(Wombat::Connector);
use fields qw(container scheme secure serverHeader started);
use strict;
use warnings;
use Apache::Request ();
use Servlet::Util::Exception ();
use Apache::Wombat::Request ();
use Apache::Wombat::Response ();
=pod
=head1 CONSTRUCTOR
=over
=item new()
Create and return an instance, initializing fields to default values.
=back
=cut
sub new {
my $self = shift;
$self = fields::new($self) unless ref $self;
$self->{container} = undef;
$self->{secure} = undef;
$self->{scheme} = 'http';
$self->{serverHeader} = undef;
$self->{started} = undef;
return $self;
}
=pod
=head1 ACCESSOR METHODS
=over
=item getContainer()
Return the Container used for processing Requests received by this
Connector.
( run in 0.442 second using v1.01-cache-2.11-cpan-cd2fffc590a )