NAME
    POE::Declare::HTTP::Server - A simple HTTP server based on POE::Declare

SYNOPSIS
        # Create the web server
        my $http = POE::Declare::HTTP::Server->new(
            Hostname => '127.0.0.1',
            Port     => '8010',
            Handler  => sub {
                my $server   = shift;
                my $response = shift;
        
            # The request is not passed to you but is available if needed
                my $request = $response->request;
        
            # Webby content generation stuff here
                $response->code( 200 );
                $response->header( 'Content-Type' => 'text/plain' );
                $response->content( "Hello World!" );
        
            return;
            },
        );
        
    # Control with methods
        $http->start;
        $http->stop;

DESCRIPTION
    This module provides a simple HTTP server based on POE::Declare.

    The implemenetation is intentionally minimalist, making this module an
    ideal choice for creating specialised web servers embedded in larger
    applications.

METHODS
  new
        my $server = POE::Declare::HTTP::Server->new(
            Hostname      => '127.0.0.1',
            Port          => '8010',
            Handler       => \&content,

            StartupEvent  => \&startup_done,
            StartupError  => \&startup_failed,
            ShutdownEvent => \&shutdown_done,
        );

    The "new" constructor sets up a reusable HTTP server that can be enabled
    and disabled repeatedly as needed.

    It takes three required parameters parameters. "Hostname", "Port" and
    "Handler".

    The "Handler" parameter should be a "CODE" reference that will be passed
    the server object and a HTTP::Response object. Your code should fill the
    provided response object, which will be sent to the client when the
    function ends. If your content will change based on the request, you can
    obtain the request from the "request" in HTTP::Response method.

    The server supports three messages you can register callbacks for.

    The "StartupEvent" message fires after the server socket has been bound
    and is available for clients to make requests, and before any
    connections have been made from clients.

    The "StartupError" message fires if the server fails to bind to the
    port, or has some other error during the socket setup process.

    The "ShutdownEvent" message fires on the completion of a controlled
    shutdown.

    There is currently no "ShutdownError" event for unexpected server
    termination, as this should not occur. An error of this type may,
    however, be added later.

  Hostname
    The "Hostname" accessor returns the server to bind to, as originally
    provided to the constructor.

  Port
    The "Port" accessor returns the port number to bind to, as originally
    provided to the constructor.

  Handler
    The "Handler" accessor returns the "CODE" reference that requests will
    be passed to, as provided to the constructor.

  start
    The "start" method enables the web server. If the server is already
    running, this method will shortcut and do nothing.

    If called before POE has been started, the web server will start
    immediately once POE is running.

  stop
    The "stop" method disables the web server. If the server is not running,
    this method will shortcut and do nothing.

SUPPORT
    Bugs should be always be reported via the CPAN bug tracker at

    <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Declare-HTTP-Server>

    For other issues, or commercial enhancement or support, contact the
    author.

AUTHORS
    Adam Kennedy <adamk@cpan.org>

SEE ALSO
    POE, <http://ali.as/>

COPYRIGHT
    Copyright 2006 - 2011 Adam Kennedy.

    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

    The full text of the license can be found in the LICENSE file included
    with this module.

