Amon2 is constructed by the following modules.
The Generic context object MUST inherit Amon2.pm.
You can use it as a context object on CLI.
The context object bootstrapping with following statement:
package MyApp;
use parent qw/Amon2/;
package main;
my $c = MyApp->bootstrap;
You can get a context object via $Amon2::CONTEXT from everywhere.
The Generic context object MUST implement the following abstract methods:
This method returns configuration data. It MUST be a hashref. Normally, this method using Amon2::Config::Simple.
The Web context object SHOULD inherit Amon2::Web and the Generic context object.
You can use it as follows:
package MyApp::Web;
use parent qw/MyApp Amon2::Web/;
package main;
my $app = MyApp::Web->to_app();
$app is a PSGI application. $app creates a new instance of MyApp::Web per request and sends it to $Amon2::CONTEXT.
The Web context object SHOULD have the following methods:
Creates a new instance of Web request object.
Creates a new instance of Web response object.
Dispatches the request to the real application.
amon2-setup.pl creates MyApp::Web::Request. It inherits an Amon2::Web::Request and Plack::Request.
In theory, you can customize it. In practice, it is fequently left untouched.
amon2-setup.pl creates MyApp::Web::Response. It inherits an Amon2::Web::Response and Plack::Response.
Normally, you don’t need to touch it. But you can customize it.