webgui/lib/WebGUI/Middleware/Debug.pm
Patrick Donelan 716bdaeb86 Added exception handling
Added error doc mapping
Moved more logic into Session middleware
Added Credit example to app.psgi
Made StackTrace and Debug panel automatically turn on when debug mode enabled
Fixed errorHandler
2010-04-10 22:52:40 -04:00

39 lines
911 B
Perl

package WebGUI::Middleware::Debug;
use strict;
use parent qw(Plack::Middleware);
use Plack::Middleware::StackTrace;
use Plack::Middleware::Debug;
use Plack::Middleware::HttpExceptions;
=head1 NAME
WebGUI::Middleware::Debug -
=head1 DESCRIPTION
This is PSGI middleware for WebGUI that
=cut
sub call {
my ( $self, $env ) = @_;
my $session = $env->{'webgui.session'} or die 'WebGUI::Session missing';
my $app = $self->app;
if ( $session->log->canShowDebug ) {
warn 'seeing webgui.debug';
$env->{'webgui.debug'} = 1;
$app = Plack::Middleware::StackTrace->wrap($app);
$app = Plack::Middleware::Debug->wrap( $app,
panels => [qw(Environment Response Timer Memory Session DBITrace PerlConfig Response)] );
}
# Turn exceptions into HTTP errors
$app = Plack::Middleware::HTTPExceptions->wrap( $app );
return $app->($env);
}
1;