Skip to content

Instantly share code, notes, and snippets.

@mishin
Forked from yko/idebug-demo.psgi
Created September 19, 2016 17:14
Show Gist options
  • Save mishin/fbc905afb760ff3182abe8448709d4ce to your computer and use it in GitHub Desktop.
Save mishin/fbc905afb760ff3182abe8448709d4ce to your computer and use it in GitHub Desktop.
PSGI InteractiveDebugger demo
#!/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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment