-
Notifications
You must be signed in to change notification settings - Fork 8
/
app_test.cpp
37 lines (28 loc) · 1.06 KB
/
app_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Simple application using the library.
*
* Just to get an idea about the size of the
* binary the library produce.
*/
//#define RESTINCURL_USE_SYSLOG 0
#define RESTINCURL_ENABLE_DEFAULT_LOGGER 1
#include "restincurl/restincurl.h"
using namespace std;
using namespace restincurl;
int main( int argc, char * argv[]) {
restincurl::Client client;
client.Build()->Get("http://localhost:3001/normal/posts")
.AcceptJson()
.Header("X-Client", "restincurl")
.Trace()
.WithCompletion([&](const Result& result) {
clog << "In callback! HTTP result code was " << result.http_response_code << endl;
clog << "Data was " << result.body.size() << " bytes." << endl;
})
.Execute();
// If the client goes out of scope, it will terminate all ongoing
// requests, so we need to wait here for the request to finish.
// Tell client that we want to close when the request is finish
client.CloseWhenFinished();
// Wait for the worker-thread in the client to quit
client.WaitForFinish();
}