Zbigniew Łukasiak > WebNano > WebNano::Controller

Download:
WebNano-0.007.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.007   Source  

NAME ^

WebNano::Controller - WebNano Controller

VERSION ^

version 0.007

DESCRIPTION ^

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.

SYNOPSIS With Moose: ^

    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;

METHODS ^

handle

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).

render

Renders a template.

local_dispatch

Finds the method to be called for a given path and dispatches to it.

req

Plack::Reqest made from env

template_search_path

search_subcontrollers

If search_subcontrollers returns true and there are no local actions then subcontrollers are searched.

dispatch_to_class

DEBUG

By default returns the DEBUG flag from the application. When this returns true then some additional logging is directed to STDOUT.

ATTRIBUTES ^

url_map

A hash that is used as path part to method map.

app

Links back to the application object.

env

PSGI environment

self_url

path

AUTHOR ^

Zbigniew Lukasiak <zby@cpan.org>

COPYRIGHT AND LICENSE ^

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)
syntax highlighting: