Browse Source

simple_http: new package (#7213)

* Add simple_http

* Limit windows/mingw

* test linux/cross/bsd/os x

* drop os x

---------

Co-authored-by: Saikari <[email protected]>
fantasy-peak 3 months ago
parent
commit
677452fbdf
1 changed files with 34 additions and 0 deletions
  1. 34 0
      packages/s/simple_http/xmake.lua

+ 34 - 0
packages/s/simple_http/xmake.lua

@@ -0,0 +1,34 @@
+package("simple_http")
+    set_kind("library", {headeronly = true})
+    set_homepage("https://github.com/fantasy-peak/simple_http")
+    set_description("A header-only HTTP library that supports both HTTP/2 and HTTP/1, based on Beast, nghttp2, and Asio.")
+    set_license("MIT")
+
+    add_urls("https://github.com/fantasy-peak/simple_http/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/fantasy-peak/simple_http.git")
+
+    add_versions("v0.1.0", "4e5b92e5f08e515437d30627c57356c69b73e38e68df57d4d9bfd0a9cc91cc2a")
+
+    add_deps("cmake")
+    add_deps("boost", {configs = {cmake = false}})
+    add_deps("nghttp2", "openssl")
+
+    on_install("linux", "cross", "bsd", function (package)
+        import("package.tools.cmake").install(package)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            simple_http::Config cfg{.ip = "0.0.0.0",
+                                    .port = 6666,
+                                    .worker_num = 4,
+                                    .concurrent_streams = 200};
+            void test() {
+                simple_http::HttpServer hs(cfg);
+                hs.setHttpHandler(
+                    "/hello", [](auto req, auto writer) -> boost::asio::awaitable<void> {
+                });
+                return;
+            }
+        ]]}, {configs = {languages = "c++20"}, includes = {"simple_http.h"}}))
+    end)