Skip to content

Instantly share code, notes, and snippets.

@miyagawa
Created September 30, 2009 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miyagawa/198482 to your computer and use it in GitHub Desktop.
Save miyagawa/198482 to your computer and use it in GitHub Desktop.
package Plack::Middleware::RequestResponseWrapper;
use strict;
use warnings;
use base qw( Plack::Middleware );
use Plack::Request;
use Plack::Response;
sub call {
my $self = shift;
my $req = Plack::Request->new(shift);
my $res = $self->app->($req);
return $res->finalize;
}
1;
__END__
=head1 NAME
Plack::Middleware::RequestResponseWrapper - Wraps your app with Plack::Request and Plack::Response
=head1 SYNOPSIS
# in app.psgi
use Plack::Builder;
use Plack::Middleware qw(RequestResponseWrapper);
my $app = sub {
my($req, $res) = @_;
$res->code(200);
$res->header('Content-Type' => 'text/plain');
$res->body('Hello World');
};
builder {
enable Plack::Middleware::RequestResponseWrapper;
$app;
};
=cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment