aboutsummaryrefslogtreecommitdiffstats
path: root/include/dbs/api.h
blob: 5d4d4fc7931e0d45c53014c6f13b84cd7b4ec041 (plain)
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
#ifndef __API_H
#define __API_H

typedef enum {
    HTTP_GET,
    HTTP_POST,
    HTTP_PUT,
    HTTP_DELETE,
    HTTP_PATCH
} HTTPMethod;

int http_request(HTTPMethod method, char *url,
        struct curl_slist *headers, char *writebuf,
        long *response_code);

int api_request(HTTPMethod method, char *url,
        struct curl_slist *headers, char *writebuf,
        long *response_code);

#define http_get(...) http_request(HTTP_GET, __VA_ARGS__)
#define http_post(...) http_request(HTTP_POST, __VA_ARGS__)
#define http_put(...) http_request(HTTP_PUT, __VA_ARGS__)
#define http_delete(...) http_request(HTTP_DELETE, __VA_ARGS__)
#define http_patch(...) http_request(HTTP_PATCH, __VA_ARGS__)

#define api_get(...) api_request(HTTP_GET, __VA_ARGS__)
#define api_post(...) api_request(HTTP_POST, __VA_ARGS__)
#define api_put(...) api_request(HTTP_PUT, __VA_ARGS__)
#define api_delete(...) api_request(HTTP_DELETE, __VA_ARGS__)
#define api_patch(...) api_request(HTTP_PATCH, __VA_ARGS__)

#endif