diff options
Diffstat (limited to 'discord/http.cpp')
-rw-r--r-- | discord/http.cpp | 31 |
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() { |