]> git.leonardobizzoni.com Git - http-lib/commitdiff
Added README master
authorLeonardoBizzoni <leo2002714@gmail.com>
Fri, 7 Feb 2025 10:44:38 +0000 (11:44 +0100)
committerLeonardoBizzoni <leo2002714@gmail.com>
Fri, 7 Feb 2025 10:44:38 +0000 (11:44 +0100)
README.org [new file with mode: 0644]

diff --git a/README.org b/README.org
new file mode 100644 (file)
index 0000000..30aba72
--- /dev/null
@@ -0,0 +1,21 @@
+* Example
+#+begin_src cpp :tangle src/main.cpp
+#include <iostream>
+#include "http.h"
+
+int main() {
+  auto server = http::Listener::on_local(8800);
+
+  server.value().routes["GET /"] = [](const http::Request &req) -> http::Response {
+    std::cout << req << std::endl;
+
+    http::Response resp;
+    resp.status = http::Status::OK;
+    resp.body = "<h1>Hello, World!</h1>";
+
+    return resp;
+  };
+
+  server.value().serve();
+}
+#+end_src