WebNano::Controller - WebNano Controller
version 0.007
This is the WebNano base controller. It's handle method dispatches the request to appropriate action method or to a next controller.
The action method should return a string containing the HTML page, a Plack::Response object or a code ref.
If there is no suitable method in the current class and the method search_subcontrollers returns a true value then child controller classes are tried out. If there is found one that matches the path part then it is instantiated with the current psgi env and it's handle method is called.
In a path /SomeDeepController/OtherController/LeaveController/method all MyApp::Controoler, MyApp::Controller::SomeDeepController and MyApp::Controller::SomeDeepController::OtherController need to override search_subcontrollers method to return 1.
/SomeDeepController/OtherController/LeaveController/method
MyApp::Controoler
MyApp::Controller::SomeDeepController
MyApp::Controller::SomeDeepController::OtherController
package MyApp::Controller; use Moose; use MooseX::NonMoose; extends 'WebNano::Controller'; has '+url_map' => ( default => sub { { 'Mapped Url' => 'mapped_url' } } ); sub index_action { my $self = shift; return $self->render( 'index.tt' ); } sub mapped_url { 'This is the mapped url page' } 1;
This is a class method - it receives the arguments, creates the controller object and then uses it's local_dispatch method.
Should return a Plack::Response object, a string containing the HTML page, a code ref or undef (which is later interpreted as 404).
Renders a template.
Finds the method to be called for a given path and dispatches to it.
Plack::Reqest made from env
If search_subcontrollers returns true and there are no local actions then subcontrollers are searched.
By default returns the DEBUG flag from the application. When this returns true then some additional logging is directed to STDOUT.
true
A hash that is used as path part to method map.
Links back to the application object.
PSGI environment
Zbigniew Lukasiak <zby@cpan.org>
This software is Copyright (c) 2010 by Zbigniew Lukasiak <zby@cpan.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install WebNano, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebNano
CPAN shell
perl -MCPAN -e shell install WebNano
For more information on module installation, please visit the detailed CPAN module installation guide.