summaryrefslogtreecommitdiff
path: root/discord/http.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-08-20 03:19:16 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-08-20 03:19:16 -0400
commita201d5905ad9188e890eeb0cc0aee8d4fb9dcf3c (patch)
treee7b28048f1150c379db1fb27e8efa032aafaf06d /discord/http.cpp
parent4b903bbd3e8436e1d63b8c12e76d8a3c924da5fc (diff)
downloadabaddon-portaudio-a201d5905ad9188e890eeb0cc0aee8d4fb9dcf3c.tar.gz
abaddon-portaudio-a201d5905ad9188e890eeb0cc0aee8d4fb9dcf3c.zip
rudimentary chat
Diffstat (limited to 'discord/http.cpp')
-rw-r--r--discord/http.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/discord/http.cpp b/discord/http.cpp
index 429a3b2..db41aa4 100644
--- a/discord/http.cpp
+++ b/discord/http.cpp
@@ -36,6 +36,37 @@ void HTTPClient::MakePOST(std::string path, std::string payload, std::function<v
{ "Content-Type", "application/json" },
};
auto body = cpr::Body { payload };
+#ifdef USE_LOCAL_PROXY
+ m_futures.push_back(cpr::GetCallback(
+ std::bind(&HTTPClient::OnResponse, this, std::placeholders::_1, cb),
+ url, headers, body,
+ cpr::Proxies { { "http", "127.0.0.1:8888" }, { "https", "127.0.0.1:8888" } },
+ cpr::VerifySsl { false }));
+#else
+ m_futures.push_back(cpr::PatchCallback(
+ std::bind(&HTTPClient::OnResponse, this, std::placeholders::_1, cb),
+ url, headers, body));
+#endif
+}
+
+void HTTPClient::MakeGET(std::string path, std::function<void(cpr::Response r)> cb) {
+ printf("POST %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::GetCallback(
+ std::bind(&HTTPClient::OnResponse, this, std::placeholders::_1, cb),
+ url, headers));
+#endif
}
void HTTPClient::CleanupFutures() {