From 68111f484bf27f03ce023497fdc5868c2b724ffb Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 29 Aug 2017 09:33:20 +0100 Subject: 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. --- perllib/FixMyStreet/App/Model/DB.pm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'perllib/FixMyStreet/App/Model/DB.pm') 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 ) = @_; -- cgit v1.2.3