From 80a67b7d20393a29aa5d2cb92197f3381be7fd96 Mon Sep 17 00:00:00 2001 From: turret Date: Sat, 30 Mar 2024 16:04:45 -0500 Subject: *: directory changes since this project is a skeleton and not meant to clutter up the code that will actually consume the bot, i've opted to consolidate the majority of files under a single directory and minimise extra files *: move code to util/ *: move include files to include/dbs/ net: consolidate net functions into single file config: remove config --- include/dbs/api.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/dbs/api.h (limited to 'include/dbs/api.h') diff --git a/include/dbs/api.h b/include/dbs/api.h new file mode 100644 index 0000000..d421f08 --- /dev/null +++ b/include/dbs/api.h @@ -0,0 +1,30 @@ +#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, size_t bufsiz); + +int api_request(HTTPMethod method, char * url, + struct curl_slist *headers, char *writebuf, size_t bufsiz); + +#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 -- cgit v1.2.3