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
39 lines
911 B
Perl
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;
|