Apache-Wombat

 view release on metacpan or  search on metacpan

docs/api/Apache/Wombat.html  view on Meta::CPAN

</DL>
<P>
<HR>
<H1><A NAME="public methods">PUBLIC METHODS</A></H1>
<DL>
<DT><STRONG><A NAME="item_handler"><CODE>handler($r)</CODE></A></STRONG><BR>
<DD>
Delegate request processing to the Wombat server. If <CODE>$ENV{HTTPS}</CODE> is
set, the request is handed to the configured secure Connector;
otherwise, the configured standard Connector gets the request.
<P>Make sure your SSL module sets <CODE>$ENV{HTTPS}</CODE>! With mod_ssl, you can
do this with <CODE>SSLOptions +StdEnvVars</CODE>.</P>
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24r">$r</A></STRONG><BR>
<DD>
the <STRONG>Apache</STRONG> request object
<P></P></DL>
</DL>
<P>
<HR>

lib/Apache/Wombat.pm  view on Meta::CPAN


Typically an instance of B<Apache::Wombat> is created at server
startup time and configured as a method handler for requests that
should be served by Wombat.

In order to use this class, mod_perl must be built with
C<PERL_METHOD_HANDLERS> enabled.

=cut

use fields qw(connector server sslConnector);
use strict;
use warnings;

use Apache ();
use Wombat '0.7.1';
use Wombat::Server ();

our $VERSION = '0.5.1';

=pod

lib/Apache/Wombat.pm  view on Meta::CPAN


sub new {
    my $self = shift;
    my $home = shift;
    my $configFile = shift;

    $self = fields::new($self) unless ref $self;

    $self->{server} = Wombat::Server->new();
    $self->{connector} = undef;
    $self->{sslConnector} = undef;

    $home ||= Apache->server_root_relative();

    $self->{server}->setHome($home);
    $self->{server}->setConfigFile($configFile) if $configFile;

    # start the server
    eval {
        $self->{server}->start();

lib/Apache/Wombat.pm  view on Meta::CPAN

        my ($service) = $self->{server}->getServices();
        die "no service configured!\n" unless $service;

        # assume at most one standard connector and one secure
        # connector, which is totally fine
        for my $connector ($service->getConnectors()) {
            if (! $self->{connector} && ! $connector->getSecure()) {
                $self->{connector} = $connector;
            }

            if (! $self->{sslConnector} && $connector->getSecure()) {
                $self->{sslConnector} = $connector;
            }

            last if $self->{connector} && $self->{sslConnector};
        }
        die "no connectors configured!\n" unless
            $self->{connector} || $self->{sslConnector};
    };
    if ($@) {
        die "problem starting service: $@\n";
    }

    Apache->push_handlers(PerlChildInitHandler =>
                          sub {
                              my $r = shift;
                              $self->{server}->await();
                          });

lib/Apache/Wombat.pm  view on Meta::CPAN

=head1 PUBLIC METHODS

=over

=item handler($r)

Delegate request processing to the Wombat server. If C<$ENV{HTTPS}> is
set, the request is handed to the configured secure Connector;
otherwise, the configured standard Connector gets the request.

Make sure your SSL module sets C<$ENV{HTTPS}>! With mod_ssl, you can
do this with C<SSLOptions +StdEnvVars>.

B<Parameters:>

=over

=item $r

the B<Apache> request object

=back

=cut

sub handler ($$) {
    my $self = shift;
    my $r = shift;

    return $ENV{HTTPS} ?
        $self->{sslConnector}->process($r) :
            $self->{connector}->process($r);
}

1;
__END__

=pod

=back



( run in 1.073 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )