mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Updated README
This commit is contained in:
parent
295e4d58aa
commit
5e37e38398
27
README.md
27
README.md
@ -50,7 +50,16 @@ svr.listen_after_bind();
|
|||||||
### Static File Server
|
### Static File Server
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
svr.set_base_dir("./www");
|
svr.set_base_dir("./www"); // This is same as `svr.set_base_dir("./www", "/")`;
|
||||||
|
```
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
svr.set_base_dir("./www", "/public");
|
||||||
|
```
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
svr.set_base_dir("./www1", "/public"); // 1st order
|
||||||
|
svr.set_base_dir("./www2", "/public"); // 2nd order
|
||||||
```
|
```
|
||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
@ -86,7 +95,7 @@ svr.Post("/multipart", [&](const auto& req, auto& res) {
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stream content with Content provider
|
### Send content with Content provider
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
const uint64_t DATA_CHUNK_SIZE = 4;
|
const uint64_t DATA_CHUNK_SIZE = 4;
|
||||||
@ -104,6 +113,20 @@ svr.Get("/stream", [&](const Request &req, Response &res) {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Receive content with Content receiver
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
svr.Post("/content_receiver",
|
||||||
|
[&](const Request &req, Response &res, const ContentReader &content_reader) {
|
||||||
|
std::string body;
|
||||||
|
content_reader([&](const char *data, size_t data_length) {
|
||||||
|
body.append(data, data_length);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
res.set_content(body, "text/plain");
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Chunked transfer encoding
|
### Chunked transfer encoding
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user