Skip to content

Commit 620560f

Browse files
committed
Project documentation has been updated
1 parent 8779895 commit 620560f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ using namespace lklibs;
123123

124124
int main() {
125125

126+
HttpClient httpClient;
127+
126128
auto future1 = httpClient.getRequest("https://api.myproject.com/foo");
127129
auto future2 = httpClient.getRequest("https://api.myproject.com/bar");
128130
auto future3 = httpClient.getRequest("https://api.myproject.com/baz");
@@ -163,6 +165,8 @@ using namespace lklibs;
163165

164166
int main() {
165167

168+
HttpClient httpClient;
169+
166170
auto response = httpClient.getRequest("https://www.myinvalidurl.com").get();
167171

168172
// Instead of throwing an exception, the succeed field of the response object is set to false
@@ -195,6 +199,8 @@ using namespace lklibs;
195199

196200
int main() {
197201

202+
HttpClient httpClient;
203+
198204
// If you need to retrieve binary data such as an image, just pass the "returnAsBinary" parameter as true
199205
auto response = httpClient.getRequest("https://api.myproject.com/image/7", true).get();
200206

@@ -222,7 +228,9 @@ using namespace lklibs;
222228

223229
int main() {
224230

225-
// You can send custom headers in a string/string map
231+
HttpClient httpClient;
232+
233+
// You can send custom headers in a string/string map
226234
auto headers = std::map<std::string, std::string>();
227235

228236
headers["Custom-Header1"] = "value1";
@@ -250,6 +258,8 @@ using namespace lklibs;
250258

251259
int main() {
252260

261+
HttpClient httpClient;
262+
253263
// You can send a POST request with form data in the payload
254264
std::string payload = "param1=7&param2=test";
255265

@@ -277,6 +287,8 @@ using namespace lklibs;
277287

278288
int main() {
279289

290+
HttpClient httpClient;
291+
280292
std::string payload = R"({"param1": 7, "param2": "test"})";
281293

282294
// You need to send the "Content-Type" as "application/json" in the HTTP Header, if you need to send json data in the payload
@@ -307,6 +319,8 @@ using namespace lklibs;
307319

308320
int main() {
309321

322+
HttpClient httpClient;
323+
310324
std::string payload = "param1=7&param2=test";
311325

312326
auto future1 = httpClient.putRequest("https://api.myproject.com", payload);

0 commit comments

Comments
 (0)