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

NAME

Amon2::LocalContext - (EXPERIMENTAL)Make context as project local

SYNOPSIS

    package MyApp;
    use parent qw(Amon2::Web);
    use Amon2::LocalContext; # 'import' method makes something

DESCRIPTION

Normally, Amon2's context is stored in 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 Amon2::LocalContext use $MyApp::CONTEXT.

METHODS

This module inserts 3 methods to your context class.

MyApp->context()

Shorthand for $MyApp::CONTEXT

MyApp->set_context($context)

It's same as:

    $MyApp::CONTEXT = $context
my $guard = MyApp->context_guard()

Create new context guard class.

It's same as:

    Amon2::ContextGuard->new(shift, \$MyApp::CONTEXT);

WARNINGS

Some plugin and your code are depended on <Amon2-context>>.

FUTURE PLAN

This behavior will be default at Amon3. (It mean I don't introduce this incompatible behavior to Amon2)