NAME
PlackX::Engine - simple request wrapper for Plack
SYNOPSIS
* case1: as standalone
use PlackX::Engine;
use Plack::Response;
my $request_handler = sub {
my $req = shift;
my $res = Plack::Response->new;
$res->code(200);
$res->header( 'Content-Type' => 'text/html' );
$res->body( "Hello World" );
};
my $engine = PlackX::Engine->new(
{
server => {
module => 'ServerSimple',
args => {
port => 3000,
host => 'localhost',
},
},
request_handler => $request_handler,
middlewares => [
{ module => "Plack::Middleware::AccessLog::Timed" },
{ module => "Plack::Middleware::Static" }
],
request_class => 'Plack::Request', # optional
}
);
$engine->run;
* case2: as psgi handler builder just create engine and return psgi_handler in example.psgi file
use PlackX::Engine;
use Plack::Response;
my $request_handler = sub {
my $req = shift;
my $res = Plack::Response->new;
$res->code(200);
$res->header( 'Content-Type' => 'text/html' );
$res->body( "Hello World" );
};
my $engine = PlackX::Engine->new(
{
request_handler => $request_handler,
middlewares => [
{ module => "Plack::Middleware::AccessLog::Timed" },
{ module => "Plack::Middleware::Static" }
],
}
);
my $psgi_handler = $engine->psgi_handler;
run your request handler with psgi
plackup -app example.psgi
DESCRIPTION
PlackX::Engine is the simple request wrapper for Plack. You want to wrap psgi env with request and response if you make application with Plack. You don't need to wrap psgi env with the request and finaize response if you use this module.
SOURCE AVAILABILITY
This source is in Github:
http://github.com/dann/p5-plackx-engine
AUTHOR
Takatoshi Kitano <kitano.tk@gmail.com>
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.