use CGI::Application::Dispatch::Server; my $server = CGI::Application::Dispatch::Server->new( class => 'MyClass::Dispatch' root_dir => '/home/project/www', ); $server->run;
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.
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.
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.
This will check the request URI and handle it appropriately, printing to STDOUT upon success. There's generally no reason to call this directly.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.