public
Last active

PSGI InteractiveDebugger demo

  • Download Gist
idebug-demo.psgi
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#!/usr/bin/env perl
use strict;
use warnings;
use Plack::Builder;
 
my $body = join '', <DATA>;
 
my $app = sub {
my $self = shift;
 
# Do whatever you want, but return PSGI-compatible response...
# ...or die.
 
# See http://search.cpan.org/~miyagawa/PSGI/PSGI.pod
 
die;
 
[200, ['Content-Type' => 'text/html'], [ $body ]];
};
 
builder {
# Enable Interactive debugging
enable "InteractiveDebugger";
 
# Make Plack middleware render some static for you
enable "Static",
path => qr{\.(?:js|css|jpe?g|gif|ico|png|html?|swf|txt)$},
root => './htdocs';
 
# Let Plack care about length header
enable "ContentLength";
 
$app;
}
 
__DATA__
<!doctype html>
<html>
 
<head>
<title>Few words about Plack and PSGI</title>
</head>
 
<body>
<h1>Hello World!</h1>
</body>
 
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.