X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=app.psgi;h=80ed1a2268195992ddfb5cc40d35226d8944b356;hb=25ed3a342819b81afaf9d04c8c6f8db372a22392;hp=b29127c24e3e1375ae8e65ea4c3ddddf98930beb;hpb=d19d29a6945493994df05ac88beb4ef38a78b77e;p=plack-app-gruntmaster.git diff --git a/app.psgi b/app.psgi index b29127c..80ed1a2 100644 --- a/app.psgi +++ b/app.psgi @@ -23,15 +23,14 @@ CSP $csp =~ s/\n/; /gr; } -my $db; +my $dbinit; sub add_database { my $app = $_[0]; sub { - my ($env) = @_; - $db //= Gruntmaster::Data->connect($ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'); - $env->{'gruntmaster.dbic'} = $db; - $app->($env) + dbinit $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:' unless $dbinit; + $dbinit = 1; + $app->(@_) } }