@@ -19,11 +19,11 @@ int main(void)
1919
2020 Server svr;
2121
22- svr.get ("/hi", [](const Request& req, Response& res) {
22+ svr.Get ("/hi", [](const Request& req, Response& res) {
2323 res.set_content("Hello World!", "text/plain");
2424 });
2525
26- svr.get (R"(/numbers/(\d+))", [&](const Request& req, Response& res) {
26+ svr.Get (R"(/numbers/(\d+))", [&](const Request& req, Response& res) {
2727 auto numbers = req.matches[1];
2828 res.set_content(numbers, "text/plain");
2929 });
@@ -32,13 +32,15 @@ int main(void)
3232}
3333```
3434
35+ `Post`, `Put`, `Delete` and `Options` methods are also supported.
36+
3537### Method Chain
3638
3739```cpp
38- svr.get ("/get", [](const auto& req, auto& res) {
40+ svr.Get ("/get", [](const auto& req, auto& res) {
3941 res.set_content("get", "text/plain");
4042 })
41- .post ("/post", [](const auto& req, auto& res) {
43+ .Post ("/post", [](const auto& req, auto& res) {
4244 res.set_content(req.body(), "text/plain");
4345 })
4446 .listen("localhost", 1234);
@@ -72,7 +74,7 @@ svr.set_error_handler([](const auto& req, auto& res) {
7274### 'multipart/form-data' POST data
7375
7476``` cpp
75- svr.post (" /multipart" , [&](const auto & req, auto & res) {
77+ svr.Post (" /multipart" , [&](const auto & req, auto & res) {
7678 auto size = req.files.size();
7779 auto ret = req.has_file("name1"));
7880 const auto& file = req.get_file_value("name1");
@@ -95,7 +97,7 @@ int main(void)
9597{
9698 httplib::Client cli("localhost", 1234);
9799
98- auto res = cli.get ("/hi");
100+ auto res = cli.Get ("/hi");
99101 if (res && res->status == 200) {
100102 std::cout << res->body << std::endl;
101103 }
@@ -105,8 +107,8 @@ int main(void)
105107### POST
106108
107109```c++
108- res = cli.post ("/post", "text", "text/plain");
109- res = cli.post ("/person", "name=john1¬e=coder", "application/x-www-form-urlencoded");
110+ res = cli.Post ("/post", "text", "text/plain");
111+ res = cli.Post ("/person", "name=john1¬e=coder", "application/x-www-form-urlencoded");
110112```
111113
112114### POST with parameters
@@ -115,7 +117,26 @@ res = cli.post("/person", "name=john1¬e=coder", "application/x-www-form-urlen
115117httplib::Map params;
116118params[" name" ] = " john" ;
117119params[" note" ] = " coder" ;
118- auto res = cli.post (" /post" , params);
120+ auto res = cli.Post(" /post" , params);
121+ ```
122+
123+ ### PUT
124+
125+ ``` c++
126+ res = cli.Post(" /resource/foo" , " text" , " text/plain" );
127+ ```
128+
129+ ### DELETE
130+
131+ ``` c++
132+ res = cli.Delete(" /resource/foo" );
133+ ```
134+
135+ ### OPTIONS
136+
137+ ``` c++
138+ res = cli.Options(" *" );
139+ res = cli.Options(" /resource/foo" );
119140```
120141
121142### Connection Timeout
@@ -130,7 +151,7 @@ httplib::Client client(url, port);
130151
131152// prints: 0 / 000 bytes => 50% complete
132153std::shared_ptr<httplib::Response> res =
133- cli.get ("/", [](uint64_t len, uint64_t total) {
154+ cli.Get ("/", [](uint64_t len, uint64_t total) {
134155 printf("%lld / %lld bytes => %d%% complete\n",
135156 len, total,
136157 (int)((len/total)*100));
@@ -150,7 +171,7 @@ httplib::Client cli("httpbin.org", 80);
150171// 'Range: bytes=1-10'
151172httplib::Headers headers = { httplib::make_range_header(1, 10) };
152173
153- auto res = cli.get ("/range/32", headers);
174+ auto res = cli.Get ("/range/32", headers);
154175// res->status should be 206.
155176// res->body should be "bcdefghijk".
156177```
@@ -185,4 +206,4 @@ The server applies gzip compression to the following MIME type contents:
185206License
186207-------
187208
188- MIT license (© 2017 Yuji Hirose)
209+ MIT license (© 2018 Yuji Hirose)
0 commit comments