Extended the usage documentation, and added additional output in the example files, as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-516803423
This commit is contained in:
parent
5b6a606f4c
commit
0eeb972b51
3 changed files with 20 additions and 7 deletions
|
|
@ -220,20 +220,23 @@ int main() {
|
|||
|
||||
// Synchronous request examples
|
||||
try {
|
||||
cout << "Example GET request to http://localhost:8080/match/123" << endl;
|
||||
auto r1 = client.request("GET", "/match/123");
|
||||
cout << r1->content.rdbuf() << endl; // Alternatively, use the convenience function r1->content.string()
|
||||
cout << "Response content: " << r1->content.rdbuf() << endl << endl; // Alternatively, use the convenience function r1->content.string()
|
||||
|
||||
cout << "Example POST request to http://localhost:8080/string" << endl;
|
||||
auto r2 = client.request("POST", "/string", json_string);
|
||||
cout << r2->content.rdbuf() << endl;
|
||||
cout << "Response content: " << r2->content.rdbuf() << endl << endl;
|
||||
}
|
||||
catch(const SimpleWeb::system_error &e) {
|
||||
cerr << "Client request error: " << e.what() << endl;
|
||||
}
|
||||
|
||||
// Asynchronous request example
|
||||
cout << "Example POST request to http://localhost:8080/json" << endl;
|
||||
client.request("POST", "/json", json_string, [](shared_ptr<HttpClient::Response> response, const SimpleWeb::error_code &ec) {
|
||||
if(!ec)
|
||||
cout << response->content.rdbuf() << endl;
|
||||
cout << "Response content: " << response->content.rdbuf() << endl;
|
||||
});
|
||||
client.io_service->run();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue