-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (26 loc) · 755 Bytes
/
main.cpp
File metadata and controls
33 lines (26 loc) · 755 Bytes
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
#include "src/Socket.h"
#include "src/Http.h"
#include "src/Response.h"
#include <stdio.h>
MNS::Server *server = NULL;
void onSignalReceived(int signum) {
if (server)
server->stop();
}
int main() {
signal(SIGTERM, onSignalReceived);
signal(SIGINT, onSignalReceived);
signal(SIGALRM, onSignalReceived);
MNS::Http *http = new MNS::Http();
server = http->createServer();
server->onHttpConnection([](MNS::SocketData *data) {
});
server->onHttpRequest([](MNS::SocketData *data) {
MNS::Response *response = data->response;
response->end("Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!", 120);
});
server->listen(8080);
server->run();
delete (http);
return 0;
}