The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CGI::Application::Dispatch::Server - A simple HTTP server for developing with CGI::Application::Dispatch

SYNOPSIS

This module is no longer maintained or recommended. Use CGI::Application::Server instead, which can do all this can and more.

  use CGI::Application::Dispatch::Server;

  my $server = CGI::Application::Dispatch::Server->new( 
             class    => 'MyClass::Dispatch' 
             root_dir => '/home/project/www',
   );
  $server->run;

DESCRIPTION

This is a simple HTTP server for for use during development with CGI::Application::Dispatch.

It's a helpful tool for working on a private copy of a website on a personal computer. It's especially useful for working offline when you don't have easy access to a full-blown webserver.

If you have customized dispatch args, it's recommended that you put them in their own class, as described in the CGI::Application::Dispatch docs. That way, they can be accessed directly through CGI::Application::Dispatch, or through here.

METHODS

new()

  my $server = CGI::Application::Dispatch::Server->new( 
        port     => '80',                # optional, defaults to 8080
        class    => 'MyClass::Dispatch', # optional, defaults CGI::Application::Dispatch
        root_dir => './alphasite',       # optional, defaults to "."
  );
   

Initialize the server. If you've subclassed CGI::Application::Dispatch to provide your own dispatch_args(), let us know that here.

If you are also serving some static content, define "root_dir" with the root directory of this content.

Other Methods You Probably Don't Need to Know About

dispatch_args()

 $server->dispatch_args(\%override_args);

This accepts a hashref of arguments and merges it into CGI::Application::Dispatch's dispatch() arguments.

Be aware that this is a shallow merge, so a top level key name in the new hash will completely replace one in the old hash with the same name.

It is recommended that you put your dispatch args in a separate class instead, as mentioned in the DESCRIPTION.

handle_request()

  $self->handle_request($cgi);

This will check the request URI and handle it appropriately, printing to STDOUT upon success. There's generally no reason to call this directly.

CAVEATS

This is a subclass of HTTP::Server::Simple and all of its caveats apply here as well.

BUGS

If you are not sure the behavior is a bug, please discuss it on the cgiapp mailing list ( cgiapp@lists.erlbaum.net ). If you feel certain if you have found a bug, please report it through rt.cpan.org.

ACKNOWLEDGEMENTS

This module was cloned from CGI::Application::Server, which in turn borrowed significant parts from HTTP::Request::AsCGI.

CONTRIBUTORS

George Hartzell <hartzell@alerce.com> Mark Stosberg

COPYRIGHT AND LICENSE

Copyright 2006 by George Hartzell

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