Skip to content

Commit

Permalink
added support for PLACK_ENV as an alternative to MOJO_MODE
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 14, 2013
1 parent b1dfa58 commit b98f89f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Mojolicious.pm
Expand Up @@ -21,7 +21,7 @@ has commands => sub {
return $commands;
};
has controller_class => 'Mojolicious::Controller';
has mode => sub { $ENV{MOJO_MODE} || 'development' };
has mode => sub { $ENV{MOJO_MODE} || $ENV{PLACK_ENV} || 'development' };
has moniker => sub { decamelize ref shift };
has plugins => sub { Mojolicious::Plugins->new };
has renderer => sub { Mojolicious::Renderer->new };
Expand Down Expand Up @@ -253,9 +253,10 @@ L<Mojolicious::Controller>.
$app = $app->mode('production');
The operating mode for your application, defaults to the value of the
MOJO_MODE environment variable or C<development>. You can also add per
mode logic to your application by defining methods named C<${mode}_mode> in
the application class, which will be called right before C<startup>.
MOJO_MODE environment variable, the value of the PLACK_ENV environment
variable or C<development>. You can also add per mode logic to your
application by defining methods named C<${mode}_mode> in the application
class, which will be called right before C<startup>.
sub development_mode {
my $self = shift;
Expand Down
8 changes: 8 additions & 0 deletions t/mojolicious/app.t
Expand Up @@ -26,6 +26,14 @@ use Test::Mojo;
'works', 'right result');
}

# Mode set with PLACK_ENV
{
local $ENV{MOJO_MODE} = '';
local $ENV{PLACK_ENV} = 'whatever';
is(Test::Mojo->new('MojoliciousConfigTest')->app->config->{it},
'works', 'right result');
}

my $t = Test::Mojo->new('MojoliciousTest');

# Application is already available
Expand Down

0 comments on commit b98f89f

Please sign in to comment.