PlackX::Engine - simple request wrapper for Plack
* 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
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.
This source is in Github:
http://github.com/dann/p5-plackx-engine
Takatoshi Kitano <kitano.tk@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install PlackX::Engine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PlackX::Engine
CPAN shell
perl -MCPAN -e shell install PlackX::Engine
For more information on module installation, please visit the detailed CPAN module installation guide.