Any-Daemon-HTTP

 view release on metacpan or  search on metacpan

lib/Any/Daemon/HTTP.pod  view on Meta::CPAN

L<new(listen)|Any::Daemon::HTTP/"METHODS">.

=item $obj-E<gt>B<workdir>()

Inherited, see L<Any::Daemon/"Accessors">

=back

=head2 Host administration

VirtualHosts and a global proxy can be added in a any order.  They
can also be added at run-time!

When a request arrives, it contains a C<Host> header which is used to
select the right object.  When a VirtualHost has this name or alias,
that will be address.  Otherwise, if there are global proxy objects,
they are tried one after the other to see whether the forwardRewrite()
reports that it accepts the request.  If this all fails, then the request
is redirected to the host named (or aliased) 'default'.  As last resort,
you get an error.

=over 4

=item $obj-E<gt>B<addProxy>($object|\%options|%options)

Add a L<Any::Daemon::HTTP::Proxy|Any::Daemon::HTTP::Proxy> object which has a C<proxy_map>,

lib/Any/Daemon/HTTP/VirtualHost.pod  view on Meta::CPAN


Connecting this server to the popular Template Toolkit web-page
framework is quite simple:

  # Use TT only for pages under /status
  $vhost->addHandler('/status' => 'ttStatus');

  sub ttStatus($$$$)
  {   my ($self, $session, $request, $uri, $tree) = @_;;

      # Often, this object is global or an attribute
      my $template = Template->new(...);

      my $output;
      my $values = {...};  # collect the values
      $template->process($fn, $values, \$output)
          or die $template->error, "\n";

      HTTP::Response->new(HTTP_OK, undef
        , ['Content-Type' => 'text/html']
        , "$output"



( run in 0.654 second using v1.01-cache-2.11-cpan-49f99fa48dc )