HTTP::Engine::Cookbook - How to cook a HTTP::Engine
The biggest advantage of using HTTP::Engine is to have one single request handler routine for your application:
HTTP::Engine
package MyApp; use HTTP::Engine::Response; sub handle_request { my ($request) = @_; # ... HTTP::Engine::Response->new( body => "Hello World" ); }
When it comes to deployment, you'll need to write additional handlers or modules based on different server environments.
The very basic and simple approach is to deploy your application as a CGI script. To do this, you need to write a CGI program like this:
## myapp.cgi #!/usr/bin/perl use MyApp; use HTTP::Engine; my $engine = HTTP::Engine->new( interface => { module => 'CGI', request_handler => \&MyApp::handle_request } ); $engine->run;
This CGI program can then be placed under the conventional cgi-bin/ directory as those defined in your server configuration.
To install HTTP::Engine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Engine
CPAN shell
perl -MCPAN -e shell install HTTP::Engine
For more information on module installation, please visit the detailed CPAN module installation guide.