aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Model/DB.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-08-29 09:33:20 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-29 16:17:34 +0100
commit68111f484bf27f03ce023497fdc5868c2b724ffb (patch)
treef8ffd8de32b1fce7925ee9759d6c808e8bcf3aca /perllib/FixMyStreet/App/Model/DB.pm
parent66bd45b66911860dd2d59e5a6e38586a1641a2d7 (diff)
Add debug toolbar middleware.
If debug is enabled, using the CATALYST_DEBUG/FIXMYSTREET_APP_DEBUG environment variables, add a debug toolbar to the output, including request/response details and a database query log. This uses Plack middleware, so works by switching our dev server to use Starman with plack directly, rather than via the script runner. We remove the GZip compression as this interferes, and take a local copy of the QueryLog::AdoptPlack trait as it needs a tweak to work. Make sure the CSP header is not output in debug mode, as that would prevent the toolbar JavaScript from running.
Diffstat (limited to 'perllib/FixMyStreet/App/Model/DB.pm')
-rw-r--r--perllib/FixMyStreet/App/Model/DB.pm5
1 files changed, 5 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Model/DB.pm b/perllib/FixMyStreet/App/Model/DB.pm
index ffd867485..db8e72c27 100644
--- a/perllib/FixMyStreet/App/Model/DB.pm
+++ b/perllib/FixMyStreet/App/Model/DB.pm
@@ -5,6 +5,7 @@ use strict;
use warnings;
use FixMyStreet;
+use Catalyst::Utils;
use Moose;
with 'Catalyst::Component::InstancePerContext';
@@ -13,6 +14,10 @@ __PACKAGE__->config(
schema_class => 'FixMyStreet::DB::Schema',
connect_info => sub { FixMyStreet::DB->schema->storage->dbh },
);
+__PACKAGE__->config(
+ traits => ['QueryLog::AdoptPlack'],
+)
+ if Catalyst::Utils::env_value( 'FixMyStreet::App', 'DEBUG' );
sub build_per_context_instance {
my ( $self, $c ) = @_;