SimplePerl

= Nginx::Simple = Nginx::Simple is a Perl module which allows for a "Apache mod_perl-like" interface. Version (0.04)

nginx.conf
perl_modules perl; perl_require Test.pm; server { listen      80; server_name localhost; location / { perl Test::handler; } }

Test.pm
package Test; use Nginx::Simple;

sub main # mandatory {  my $self = shift;

$self->header_set('Content-Type' => 'text/html'); $self->print('rock on!');

$self->log('I found a rabbit...');

my $something = $self->param("here"); $self->print("I found $something..."); }

sub cleanup {  my $self = shift;
 * 1) (optional) triggered after main runs

# do stuff here---like clean database connections? }

sub error {  my $self = shift; my $error = shift; $self->status(500); $self->print("oh, uh, there is an error! ($error)"); }
 * 1) (optional) triggered on a server error, otherwise it will return a standard nginx 500 error

CPAN module: http://search.cpan.org/dist/Nginx-Simple/lib/Nginx/Simple.pm