Domanda

I am trying to use Plack::Middleware::DBIC::QueryLog inside of a dancer application. The documentation tells me to get the querylog like this:

use Plack::Middleware::DBIC::QueryLog;
sub get_querylog_from_env {
  my ($self, $env) = @_;
  Plack::Middleware::DBIC::QueryLog->get_querylog_from_env($env);
}

In my dancer app before accessing my database schema I have to set $schema->storage->debugobj to the QueryLogger. My question is: How can I access the environment $env provided by Plack which contains the QueryLog object I'm supposed to use?

I am starting my dancer application with

plackup bin/app.pl

where app.pl contains the default

use Dancer;
use app;
dance;
È stato utile?

Soluzione

Have you tried

request->env();

from within your app.pm itself? See Dancer::Request. It's not a Plack::Request object, but judging from the source, it does contain PSGI ENV vars.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top