- Easy-to-use client API inspired by Python [requests](https://2.python-requests.org//en/master/)
@ -26,6 +42,8 @@ Git repo: https://github.com/sprinfall/webcc. Please check this one instead of t
## Client API
### A Complete Example
Let's start from a complete client example:
```cpp
@ -60,6 +78,8 @@ int main() {
}
```
### Request Builder
As you can see, a helper class named `RequestBuilder` is used to chain the parameters and finally build a request object. Please pay attention to the `()` operator.
URL query parameters can be easily added through `Query()` method:
Webcc has the ability to stream large response data to a file. This is especially useful when downloading files.
```cpp
@ -149,6 +181,8 @@ auto r = session.Send(webcc::RequestBuilder{}.
r->file_body()->Move("./wolf.jpeg");
```
### Upload Files
Streaming is also available for uploading:
```cpp
@ -162,11 +196,13 @@ The file will not be loaded into the memory all at once, instead, it will be rea
Please note that `Content-Length` header will still be set to the true size of the file, this is different from the handling of chunked data (`Transfer-Encoding: chunked`).
Please check the [examples](examples/) for more information.
Please check the [examples](examples/) for more information.
## Server API
### Hello, World!
### Hello World
Run the following example, open your browser with `localhost:8080`, you should see "Hello, World!".
```cpp
class HelloView : public webcc::View {
@ -196,7 +232,7 @@ int main() {
}
```
### Book Server
### REST Book Server
Suppose you want to create a book server and provide the following operations with RESTful API: