/
restclient.h
68 lines (58 loc) · 1.73 KB
/
restclient.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* @file restclient.h
* @brief libcurl wrapper for REST calls
* @author Daniel Schauenberg <d@unwiredcouch.com>
* @version
* @date 2010-10-11
*/
#ifndef INCLUDE_RESTCLIENT_CPP_RESTCLIENT_H_
#define INCLUDE_RESTCLIENT_CPP_RESTCLIENT_H_
#include <string>
#include <map>
#include <cstdlib>
#include "restclient-cpp/version.h"
/**
* @brief namespace for all RestClient definitions
*/
namespace RestClient {
/**
* public data definitions
*/
typedef std::map<std::string, std::string> HeaderFields;
/** @struct Response
* @brief This structure represents the HTTP response data
* @var Response::code
* Member 'code' contains the HTTP response code, or cURL error code
* @var Response::body
* Member 'body' contains the HTTP response body, or curl_easy_strerror output
* @var Response::headers
* Member 'headers' contains the HTTP response headers
*/
typedef struct {
int code;
std::string body;
HeaderFields headers;
} Response;
// init and disable functions
int init();
void disable();
/**
* public methods for the simple API. These don't allow a lot of
* configuration but are meant for simple HTTP calls.
*
*/
Response get(const std::string& url);
Response post(const std::string& url,
const std::string& content_type,
const std::string& data);
Response put(const std::string& url,
const std::string& content_type,
const std::string& data);
Response patch(const std::string& url,
const std::string& content_type,
const std::string& data);
Response del(const std::string& url);
Response head(const std::string& url);
Response options(const std::string& url);
} // namespace RestClient
#endif // INCLUDE_RESTCLIENT_CPP_RESTCLIENT_H_