Browse Source

Updated README

yhirose 6 years ago
parent
commit
e0d327558d
2 changed files with 16 additions and 14 deletions
  1. 13 12
      README.md
  2. 3 2
      test/test.cc

+ 13 - 12
README.md

@@ -31,6 +31,10 @@ int main(void)
         res.set_content(numbers, "text/plain");
     });
 
+    svr.Get("/stop", [&](const Request& req, Response& res) {
+      svr.stop();
+    });
+
     svr.listen("localhost", 1234);
 }
 ```
@@ -44,18 +48,6 @@ int port = svr.bind_to_any_port("0.0.0.0");
 svr.listen_after_bind();
 ```
 
-### Method Chain
-
-```cpp
-svr.Get("/get", [](const auto& req, auto& res) {
-        res.set_content("get", "text/plain");
-    })
-    .Post("/post", [](const auto& req, auto& res) {
-        res.set_content(req.body(), "text/plain");
-    })
-    .listen("localhost", 1234);
-```
-
 ### Static File Server
 
 ```cpp
@@ -114,6 +106,15 @@ int main(void)
 }
 ```
 
+### GET with HTTP headers
+
+```c++
+  httplib::Headers headers = {
+    { "Content-Length", "5" }
+  };
+  auto res = cli.Post("/validate-no-multiple-headers", headers, "hello", "text/plain");
+```
+
 ### GET with Content Receiver
 
 ```c++

+ 3 - 2
test/test.cc

@@ -1157,8 +1157,9 @@ TEST_F(ServerTest, ArrayParam) {
 }
 
 TEST_F(ServerTest, NoMultipleHeaders) {
-  Headers headers;
-  headers.emplace("Content-Length", "5");
+  Headers headers = {
+    { "Content-Length", "5" }
+  };
   auto res = cli_.Post("/validate-no-multiple-headers", headers, "hello",
                        "text/plain");
   ASSERT_TRUE(res != nullptr);