forked from Mons/AnyEvent-HTTP-Server-II
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
55 lines (41 loc) · 1.33 KB
/
README
File metadata and controls
55 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
NAME
AnyEvent::HTTP::Server - AnyEvent HTTP/1.1 Server
SYNOPSIS
use AnyEvent::HTTP::Server;
my $s = AnyEvent::HTTP::Server->new(
host => '0.0.0.0',
port => 80,
cb => sub {
my $req = shift;
return sub {
my ($is_last, $bodypart) = @_;
$r->reply(200, "<h1>Reply message</h1>", headers => { 'content-type' => 'text/html' });
}
}
);
$s->listen;
## you may also prefork on N cores:
# fork() ? next : last for (1..$N-1);
## Of course this is very simple example
## don't use such prefork in production
$s->accept;
my $sig = AE::signal INT => sub {
warn "Stopping server";
$s->graceful(sub {
warn "Server stopped";
EV::unloop;
});
};
EV::loop;
RESOURCES
* GitHub repository
<http://github.com/Mons/AnyEvent-HTTP-Server>
ACKNOWLEDGEMENTS
* Thanks to Marc Lehmann for AnyEvent
* Thanks to Robin Redeker for AnyEvent::HTTPD
AUTHOR
Mons Anderson, <mons@cpan.org>
LICENSE
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.