Browse Source

Updated README

yhirose 8 years ago
parent
commit
d2982531bd
1 changed files with 33 additions and 2 deletions
  1. 33 2
      README.md

+ 33 - 2
README.md

@@ -7,11 +7,11 @@ A C++11 header-only HTTP library.
 
 
 It's extremely easy to setup. Just include **httplib.h** file in your code!
 It's extremely easy to setup. Just include **httplib.h** file in your code!
 
 
+Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.com/visionmedia/express).
+
 Server Example
 Server Example
 --------------
 --------------
 
 
-Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.com/visionmedia/express).
-
 ```c++
 ```c++
 #include <httplib.h>
 #include <httplib.h>
 
 
@@ -71,9 +71,24 @@ svr.set_error_handler([](const auto& req, auto& res) {
 });
 });
 ```
 ```
 
 
+### `multipart/form-data` POST data
+
+```cpp
+svr.post("/multipart", [&](const auto& req, auto& res) {
+    auto size = req.files.size();
+    auto ret = req.has_file("name1"));
+    const auto& file = req.get_file_value("name1");
+    // file.filename;
+    // file.content_type;
+    auto body = req.body.substr(file.offset, file.length));
+})
+```
+
 Client Example
 Client Example
 --------------
 --------------
 
 
+### GET
+
 ```c++
 ```c++
 #include <httplib.h>
 #include <httplib.h>
 #include <iostream>
 #include <iostream>
@@ -89,6 +104,22 @@ int main(void)
 }
 }
 ```
 ```
 
 
+### POST
+
+```c++
+res = cli.post("/post", "text", "text/plain");
+res = cli.post("/person", "name=john1&note=coder", "application/x-www-form-urlencoded");
+```
+
+### POST with parameters
+
+```c++
+httplib::Map params;
+params["name"] = "john";
+params["note"] = "coder";
+auto res = cli.post("/post", params);
+```
+
 ### With Progress Callback
 ### With Progress Callback
 
 
 ```cpp
 ```cpp