diff --git a/README.md b/README.md index 2bd2345..bc5a0ef 100644 --- a/README.md +++ b/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++ diff --git a/test/test.cc b/test/test.cc index d2eb3ef..9526b1e 100644 --- a/test/test.cc +++ b/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);