The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Amon2::Web - Web Application Base.

SYNOPSIS

    package MyApp;
    use parent qw/Amon2/;

    package MyApp::Web;
    use parent qw/MyApp Amon2::Web/;

DESCRIPTION

This is a web application base class.

METHODS

$c->create_request()

Create new request object from $c.

You can override this method to change request object's class.

$c->create_response($code, \@headers, \@body)

Create new response object.

You can override this method to change response object's class.

$c->create_view()

Create new view object. View object should have $view->render(@_) method.

You can override this method to change view object's class.

$c->dispatch() : Plack::Response

Do dispatch request. This method must return instance of Plack::Response.

You can override this method to change behavior.

$c->html_content_type() : Str

Returns default Content-Type value for the HTML response.

You can override this method to change behavior.

$c->request() : Plack::Request
$c->req() : Plack::Request

This is a accessor method to get request object in this context.

$c->redirect($location : Str, \%parameters) : Plack::Response

Create a response object to redirect for $location with \%parameters.

    $c->redirect('/foo', +{bar => 3})

is same as following(if base URL is http://localhost:5000/)

    $c->create_response(302, [Location => 'http://localhost:5000/foo?bar=3'])
$c->res_404()

Create new response object has 404 status code.

MyApp->to_app() : CodeRef

Create instance of PSGI application.

$c->uri_for($path: Str, \%args) : Str

Create URI from $path and \%args.

This method returns relative URI.

$c->render($tmpl[, @args|%args]) : Plack::Web::Response

This method render HTML.

$c->encoding()

Return a encoding object using Encode::find_encoding().

You can override this method to change behavior.

$c->encode_html($html) : Str

This method encode HTML from bytes.

You can override this method to change behavior.