1
0
mirror of synced 2025-04-21 22:25:55 +03:00

Updated README

This commit is contained in:
yhirose 2020-12-21 13:40:32 -05:00
parent 55f57af0b9
commit 96afa7e108

View File

@ -15,8 +15,13 @@ Simple examples
#### Server #### Server
```c++ ```c++
// HTTP
httplib::Server svr; httplib::Server svr;
// HTTPS
#define CPPHTTPLIB_OPENSSL_SUPPORT
httplib::SSLServer svr;
svr.Get("/hi", [](const httplib::Request &, httplib::Response &res) { svr.Get("/hi", [](const httplib::Request &, httplib::Response &res) {
res.set_content("Hello World!", "text/plain"); res.set_content("Hello World!", "text/plain");
}); });
@ -27,12 +32,14 @@ svr.listen("0.0.0.0", 8080);
#### Client #### Client
```c++ ```c++
#define CPPHTTPLIB_OPENSSL_SUPPORT // HTTP
httplib::Client cli("http://cpp-httplib-server.yhirose.repl.co");
// HTTPS
#define CPPHTTPLIB_OPENSSL_SUPPORT
httplib::Client cli("https://cpp-httplib-server.yhirose.repl.co"); httplib::Client cli("https://cpp-httplib-server.yhirose.repl.co");
auto res = cli.Get("/hi"); auto res = cli.Get("/hi");
res->status; res->status;
res->body; res->body;
``` ```