Amon2 - lightweight web application framework
package MyApp; use parent qw/Amon2/; use Amon2::Config::Simple; sub load_config { Amon2::Config::Simple->load(shift) }
Amon2 is simple, readable, extensible, STABLE, FAST web application framework based on Plack.
Amon2
Get the context object.
Set your context object(INTERNAL USE ONLY).
MyApp->config()
This method returns configuration information. It is generated by MyApp->load_config().
MyApp->load_config()
MyApp->mode_name()
This is a mode name for Amon2. The default implementation of this method is:
sub mode_name { $ENV{PLACK_ENV} }
You can override this method if you want to determine the mode by other method.
MyApp->new()
Create new context object.
MyApp->bootstrap()
my $c = MyApp->bootstrap();
Create new context object and set it to global context. When you are writing CLI script, setup the global context object by this method.
MyApp->base_dir()
This method returns the application base directory.
MyApp->load_plugin($module_name[, \%config])
This method loads the plugin for the application.
$module_name package name of the plugin. You can write it as two form like DBIx::Class:
__PACKAGE__->load_plugin("Web::HTTPSession"); # => loads Amon2::Plugin::Web::HTTPSession
If you want to load a plugin in your own name space, use the '+' character before a package name, like following: __PACKAGE__->load_plugin("+MyApp::Plugin::Foo"); # => loads MyApp::Plugin::Foo
MyApp->load_plugins($module_name[, \%config ], ...)
Load multiple plugins at one time.
If you want to load a plugin in your own name space, use the '+' character before a package name like following:
__PACKAGE__->load_plugins("+MyApp::Plugin::Foo"); # => loads MyApp::Plugin::Foo
You can get a configuration hashref from config/$ENV{PLACK_ENV}.pl. You can override this method for customizing configuration loading method.
config/$ENV{PLACK_ENV}.pl
MyApp->add_config()
DEPRECATED.
MyApp->debug_mode()
((EXPERIMENTAL))
This method returns a boolean value. It returns true when $ENV{AMON2_DEBUG} is true value, false otherwise.
You can override this method if you need.
THIS MODE IS HIGHLY EXPERIMENTAL
Normally, Amon2's context is stored in a global variable.
This module makes the context to project local.
It means, normally context class using Amon2 use $Amon2::CONTEXT in each project, but context class using "PROJECT LOCAL MODE" use $MyApp::CONTEXT.
$Amon2::CONTEXT
$MyApp::CONTEXT
It means you can't use code depend <Amon2-context>> and <Amon2-context>> under this mode.>
<Amon2-
Older Amon2::Web::Request has only 1 argument like following, it uses Amon2->context to get encoding:
Amon2->context
sub create_request { my ($class, $env) = @_; Amon2::Web::Request->new($env); }
If you want to use "PROJECT LOCAL MODE", you need to pass class name of context class, as following:
sub create_request { my ($class, $env) = @_; Amon2::Web::Request->new($env, $class); }
MyApp-make_local_context() > turns on the project local mode.
MyApp-
There is no way to revert it, thanks.
This module inserts 3 methods to your context class.
Shorthand for $MyApp::CONTEXT
It's the same as:
$MyApp::CONTEXT = $context
Create new context guard class.
Amon2::ContextGuard->new(shift, \$MyApp::CONTEXT);
More complicated documents are available on http://amon.64p.org/
#amon at irc.perl.org is also available.
Tokuhiro Matsuno <tokuhirom@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Amon2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Amon2
CPAN shell
perl -MCPAN -e shell install Amon2
For more information on module installation, please visit the detailed CPAN module installation guide.