AnyEvent::Plackup - Easily establish an HTTP server inside a program
use AnyEvent::Plackup; my $server = plackup(); # port is automatically chosen my $req = $server->recv; # isa Plack::Request my $value = $req->parameters->{foo}; $req->respond([ 200, [], [ 'OK' ] ]); # or specify PSGI app: my $server = plackup(app => \&app);
AnyEvent::Plackup provides functionality of establishing an HTTP server inside a program using Twiggy. If not specified, open port is automatically chosen.
my $server = AnyEvent::Plackup->new([ app => \&app, port => $port, %args ])
my $server = plackup([ app => \&app, port => $port, %args ])
Creates and starts an HTTP server. Internally calls new and run.
new
run
If app is not specified, $server->recv is available and you should respond this manually.
$server->recv
my $req = $server->recv
Waits until next request comes. Returns an AnyEvent::Plackup::Request (isa Plack::Request).
AnyEvent::Plackup::Request
Plack::Request
my $origin = $server->origin
my $origin = "$server"
Returns server's origin. e.g. "http://0.0.0.0:8290".
"http://0.0.0.0:8290"
$server->shutdown
Shuts down the server immediately.
motemen <motemen@gmail.com>
Twiggy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install AnyEvent::Plackup, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::Plackup
CPAN shell
perl -MCPAN -e shell install AnyEvent::Plackup
For more information on module installation, please visit the detailed CPAN module installation guide.