summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/http.cpp20
-rw-r--r--discord/http.hpp1
2 files changed, 21 insertions, 0 deletions
diff --git a/discord/http.cpp b/discord/http.cpp
index d08fefe..454324e 100644
--- a/discord/http.cpp
+++ b/discord/http.cpp
@@ -7,6 +7,26 @@ void HTTPClient::SetAuth(std::string auth) {
m_authorization = auth;
}
+void HTTPClient::MakeDELETE(std::string path, std::function<void(cpr::Response r)> cb) {
+ printf("DELETE %s\n", path.c_str());
+ auto url = cpr::Url { m_api_base + path };
+ auto headers = cpr::Header {
+ { "Authorization", m_authorization },
+ { "Content-Type", "application/json" },
+ };
+#ifdef USE_LOCAL_PROXY
+ m_futures.push_back(cpr::GetCallback(
+ std::bind(&HTTPClient::OnResponse, this, std::placeholders::_1, cb),
+ url, headers,
+ cpr::Proxies { { "http", "127.0.0.1:8888" }, { "https", "127.0.0.1:8888" } },
+ cpr::VerifySsl { false }));
+#else
+ m_futures.push_back(cpr::DeleteCallback(
+ std::bind(&HTTPClient::OnResponse, this, std::placeholders::_1, cb),
+ url, headers));
+#endif
+}
+
void HTTPClient::MakePATCH(std::string path, std::string payload, std::function<void(cpr::Response r)> cb) {
printf("PATCH %s\n", path.c_str());
auto url = cpr::Url { m_api_base + path };
diff --git a/discord/http.hpp b/discord/http.hpp
index 7a72589..b8489f9 100644
--- a/discord/http.hpp
+++ b/discord/http.hpp
@@ -19,6 +19,7 @@ public:
HTTPClient(std::string api_base);
void SetAuth(std::string auth);
+ void MakeDELETE(std::string path, std::function<void(cpr::Response r)> cb);
void MakeGET(std::string path, std::function<void(cpr::Response r)> cb);
void MakePATCH(std::string path, std::string payload, std::function<void(cpr::Response r)> cb);
void MakePOST(std::string path, std::string payload, std::function<void(cpr::Response r)> cb);