Gantry::Server - HTTP::Server::Simple::CGI subclass providing stand alone server
#!/usr/bin/perl use strict; use Gantry::Server; use lib '/home/myhome/lib'; use YourApp qw{ -Engine=CGI -TemplateEngine=Default }; my $cgi_engine = Gantry::Engine::CGI->new(); $cgi_engine->add_location( '/', 'YourApp' ); my $server = Gantry::Server->new(); # pass a port number to the above constructor if you don't want 8080. $server->set_engine_object( $cgi_engine ); $server->run();
This module subclasses HTTP::Server::Simple::CGI to provide a stand alone server for any Gantry app. Pretend you are deploying to a CGI environment, but replace
$cgi_engine->dispatch();
with
use Gantry::Server; my $server = Gantry::Server->new(); $server->set_engine_object( $cgi_engine ); $server->run();
Note that you must call set_engine_object before calling run, and you must pass it a valid Gantry::Engine::CGI object with the proper locations and config definitions.
By default, your server will start on port 8080. If you want a different port, pass it to the constructor. You can generate the above script, with port control, in bigtop by doing this in your config section:
config { engine CGI; CGI Gantry { with_server 1; } #... } app YourApp { #... }
You must call this before calling run. Pass it a Gantry::Engine::CGI object.
This starts the server and never returns.
This method overrides the parent version to avoid taking form parameters prematurely.
This method functions as a little web server processing http requests (but it leans heavily on HTTP::Server::Simple::CGI).
This method pretends to be a web server, but only handles a single request before returning. This is useful for testing your Gantry app without having to use sockets.
This is the same as handle_request_test, but it treats the request as a POST. This is mainly used for form testing.
This method is like handle_request_test, but for SOAP packets. Call it with the location you want to hit and the XML packet to PUT there. Returns whatever the server returns.
handle_request_test
Retrieves the defined Net::Sever engine type
optionaly you can set a Net::Sever engine type ( see Net::Server ).
$server->set_net_server( 'Net::Server::PreForkSimple' );
Builds and sets the SERVER_URL environment variable.
Phil Crow <philcrow2000@yahoo.com>
Copyright (c) 2006, Phil Crow.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Gantry, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gantry
CPAN shell
perl -MCPAN -e shell install Gantry
For more information on module installation, please visit the detailed CPAN module installation guide.