mirror of
https://github.com/uowuo/abaddon.git
synced 2024-11-10 06:00:10 +00:00
add HTTPClient::MakeDELETE
This commit is contained in:
parent
08e9d2f0ef
commit
fbd8ed2ba7
@ -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 };
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user