Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/motemen/perl5-anyevent-plackup
Easily establish an HTTP server inside a program
https://github.com/motemen/perl5-anyevent-plackup
Last synced: about 2 months ago
JSON representation
Easily establish an HTTP server inside a program
- Host: GitHub
- URL: https://github.com/motemen/perl5-anyevent-plackup
- Owner: motemen
- License: other
- Created: 2012-09-16T14:35:16.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-10-21T04:58:16.000Z (over 11 years ago)
- Last Synced: 2024-10-15T15:29:56.185Z (3 months ago)
- Language: Perl
- Size: 168 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
AnyEvent::Plackup - Easily establish an HTTP server inside a program
# SYNOPSIS
use AnyEvent::Plackup;
my $server = plackup(); # port is automatically chosen
my $req = $server->recv; # isa Plack::Requestmy $value = $req->parameters->{foo};
$req->respond([ 200, [], [ 'OK' ] ]);
# or specify PSGI app:
my $server = plackup(app => \&app);
# DESCRIPTION
AnyEvent::Plackup provides functionality of establishing an HTTP server inside a program using [Twiggy](http://search.cpan.org/perldoc?Twiggy). If not specified, open port is automatically chosen.
# FUNCTIONS
- `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`.
If _app_ is not specified, `$server->recv` is available and you should respond this manually.
- `my $req = $server->recv`
Waits until next request comes. Returns an `AnyEvent::Plackup::Request` (isa `Plack::Request`).
- `my $origin = $server->origin`
- `my $origin = "$server"`Returns server's origin. e.g. `"http://0.0.0.0:8290"`.
- `$server->shutdown`
Shuts down the server immediately.
# AUTHOR
motemen
# SEE ALSO
[Twiggy](http://search.cpan.org/perldoc?Twiggy)
# LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.