diff options
author | turret <turret@duck.com> | 2024-01-18 18:52:27 -0600 |
---|---|---|
committer | turret <turret@duck.com> | 2024-01-18 18:52:27 -0600 |
commit | e6c7c2f3d683a5c15e2be15563e2f52d8aed91ed (patch) | |
tree | d2619b8e6e7c37ff799276170cb33beb99b0d649 /include | |
parent | 694ea524ca6e2d08bb648ded5c45d455a7b5d340 (diff) | |
download | discord-bot-skeleton-e6c7c2f3d683a5c15e2be15563e2f52d8aed91ed.tar.gz discord-bot-skeleton-e6c7c2f3d683a5c15e2be15563e2f52d8aed91ed.tar.bz2 discord-bot-skeleton-e6c7c2f3d683a5c15e2be15563e2f52d8aed91ed.zip |
api: extensify api api
Diffstat (limited to 'include')
-rw-r--r-- | include/api.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/api.h b/include/api.h new file mode 100644 index 0000000..a70d447 --- /dev/null +++ b/include/api.h @@ -0,0 +1,35 @@ +#ifndef __API_H +#define __API_H +#define _Nullable + +typedef enum { + HTTP_GET, + HTTP_POST, + HTTP_PUT, + HTTP_DELETE, + HTTP_PATCH +} HTTPMethod; + +#ifndef __API_INTERNAL + +int http_request(HTTPMethod method, char *url, + struct curl_slist *_Nullable headers, char *writebuf, size_t bufsiz); + +int api_request(HTTPMethod method, char * url, + struct curl_slist *_Nullable headers, char *writebuf, size_t bufsiz); + +#endif + +#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 |