Hi! Please consider following me on twitter: @hanekomu.

Plack::Middleware::Debug

I wrote and released a new middleware for Plack: Plack::Middleware::Debug. It was on miyagawa's wishlist for Plack and is based heavily on the Django Debug Toolbar. miyagawa also helped to get this middleware in proper shape to play nicely with the rest of Plack.

Here is an example of how to use it. Put this in your app.psgi:

use Plack::Builder;
use File::Basename;

my $app = sub { ... };

builder {
    enable 'Debug', panels =>
        [ qw(Environment Response Timer Memory DBITrace) ];
    $app;
};

The debug middleware offers a configurable set of panels that displays information about the current request and response. The information is generated only for responses with a status of 200 (OK) and a Content-Type that contains text/html and is embedded in the HTML that is sent back to the browser.

If you pass a list of panel base names to the enable() call, only those panels will be enabled. If you don't pass an argument, the default list of panels — Environment, Response, Timer and Memory — will be enabled.

As of version 0.01, the following panels are available:

The following two screenshots demonstrate the DBITrace and Environment panels.

Plack::Middleware::Debug::DBITrace

Plack::Middleware::Debug::Environment

You could use the power of the debug toolbar for your own framework or web application. It is quite easy to write custom panels. Just subclass Plack::Middleware::Debug::Base, then use your panel in the enable() call.

If you are interested, join us on #plack on irc.perl.org. The development repository is on GitHub.

Write a comment | Bookmark and Share

posted at: 12:04 | path: /dev | permalink | 0 comments | 1 trackback

uberVU - social comments mentioned this post in "Social comments and analytics for this post"This post was mentioned on Twitter by hanekomu: blogged http://hanekomu.at/blog/dev/20091213-1204-plack_middleware_debug.html #plack

eq="">.

This post was mentioned on Twitter by hanekomu: blogged http://hanekomu.at/blog/dev/20091213-1204-plack_middleware_debug.html #plack

ne="">:

This post was mentioned on Twitter by hanekomu: blogged http://hanekomu.at/blog/dev/20091213-1204-plack_middleware_debug.html #plack

Comments are closed for this story.

Trackbacks are closed for this story.