NAME

Nginx::Simple::Dispatch - Easy to use dispatcher interface for "--with-http_perl_module"

SYNOPSIS

For an "instant working example" please see the ./testdrive-example directory.

MainPage.pm:

package MainPage;

# app_path is where the application's URI begins
# auto_import allows for lazyloading of application modules
use Nginx::Simple::Dispatch( app_path => '/foo', auto_import => 1 );
use strict;

sub index :Index {
    my $self = shift;

    $self->print('I am the main page people will see.');
}

sub about :Action {
    my $self = shift;

    $self->print('Let us pretend the about page goes here, shall we?');
}

sub error {
    my $self = shift;
    my $self->get_error;
    my @stack = $self->error_stack;

    $self->status(500);
    $self->print('Something blew up! Kaboooooom!<hr>');
    $self->print("Details: <pre>$error</pre>");

    $self->cleanup;
}

sub bad_dispatch {
    my $self = shift;
    my $error = shift;

    $self->status(404);
    $self->print('Page not found.');
}

# do something after we do something
sub cleanup
{
    warn "[looging dragons: good]\n";
}

1;

MainPage/weather.pm

package MainPage::weather;

use base 'MainPage';
use strict;

sub index :Index {
    my $self = shift;

    $self->print("zap zap ook");
}

sub corn :Action {
    my $self = shift;

    $self->print("men");
}

1;

Author

Michael J. Flickinger, <mjflick@gnu.org>

Copyright & License

You may distribute under the terms of either the GNU General Public License or the Artistic License.