How Project Local Mode works
masterConcept
Normally, Amon2 stores the application context in a global variable ($Amon2::CONTEXT). In Project Local Mode, the context is moved to a project-specific variable ($MyApp::CONTEXT).
Warning: This mode is highly experimental.
Implications
- You cannot use code that depends on
<Amon2-context'>> or<Amon2-context'>>` while in this mode. - If you are overriding
create_requestinAmon2::Web::Request, you must pass the class name of your context class as the second argument to ensure it uses the local context instead of the global one.
Enabling Project Local Mode
Call MyApp->make_local_context() to enable this mode. Note that there is no way to revert this setting once enabled.
sub create_request {
my ($class, $env) = @;
# Required for Project Local Mode
Amon2::Web::Request->new($env, $class);
}