-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathcpp-httplib.yaml
87 lines (72 loc) · 1.92 KB
/
cpp-httplib.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Generated from https://git.alpinelinux.org/aports/plain/main/cxxopts/APKBUILD
package:
name: cpp-httplib
version: "0.20.0"
epoch: 0
description: C++ header-only HTTP/HTTPS server and client library
copyright:
- license: MIT
environment:
contents:
packages:
- build-base
- busybox
- ca-certificates-bundle
- cmake
- ninja
pipeline:
- uses: git-checkout
with:
repository: https://github.com/yhirose/cpp-httplib.git
tag: v${{package.version}}
expected-commit: 787a34ad7f01f20922a237d5142aae469828be72
recurse-submodules: true
- uses: cmake/configure
- uses: cmake/build
- uses: cmake/install
- uses: strip
update:
enabled: true
github:
identifier: yhirose/cpp-httplib
strip-prefix: v
use-tag: true
test:
environment:
contents:
packages:
- build-base
- curl
pipeline:
- runs: |
cat << 'EOF' > server.cpp
#include "httplib.h"
int main() {
httplib::Server svr;
svr.Get("/hi", [](const httplib::Request &, httplib::Response &res) {
res.set_content("Hello World!", "text/plain");
});
svr.listen("0.0.0.0", 8080);
}
EOF
g++ server.cpp -o server
./server &
[ "$(curl --fail http://127.0.0.1:8080/hi)" = "Hello World!" ]
cat << 'EOF' > client.cpp
#include <httplib.h>
#include <iostream>
int main(void)
{
httplib::Client cli("localhost", 8080);
if (auto res = cli.Get("/hi")) {
if (res->status == httplib::StatusCode::OK_200) {
std::cout << res->body << std::endl;
}
} else {
auto err = res.error();
std::cout << "HTTP error: " << httplib::to_string(err) << std::endl;
}
}
EOF
g++ client.cpp -o client
[ "$(./client)" = "Hello World!" ]