GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Nginx::Simple::Dispatch(3) User Contributed Perl Documentation Nginx::Simple::Dispatch(3)

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

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;

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

You may distribute under the terms of either the GNU General Public License or the Artistic License.
2011-02-18 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.