forked from wfrest/wfrest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19_https.cc
More file actions
45 lines (37 loc) · 828 Bytes
/
Copy path19_https.cc
File metadata and controls
45 lines (37 loc) · 828 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
34
35
36
37
38
39
40
41
42
43
44
45
#include "workflow/WFFacilities.h"
#include <csignal>
#include "wfrest/HttpServer.h"
using namespace wfrest;
static WFFacilities::WaitGroup wait_group(1);
void sig_handler(int signo)
{
wait_group.done();
}
int main(int argc, char **argv)
{
// in cert file
// sudo ./gen.sh to generate crt / key files
if (argc != 3)
{
fprintf(stderr, "%s [cert file] [key file]\n",
argv[0]);
exit(1);
}
signal(SIGINT, sig_handler);
HttpServer svr;
// curl -v https://ip:port/https
svr.GET("/https", [](const HttpReq *req, HttpResp *resp)
{
resp->String("Test Https\n");
});
if (svr.start(8888, argv[1], argv[2]) == 0)
{
wait_group.wait();
svr.stop();
} else
{
fprintf(stderr, "Cannot start server\n");
exit(1);
}
return 0;
}