|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
#define WEBCC_ASYNC_REST_CLIENT_H_
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <utility> // for move()
|
|
|
|
|
|
|
|
|
|
#include "webcc/async_http_client.h"
|
|
|
|
|
|
|
|
|
@ -10,8 +11,7 @@ namespace webcc {
|
|
|
|
|
class AsyncRestClient {
|
|
|
|
|
public:
|
|
|
|
|
AsyncRestClient(boost::asio::io_context& io_context, // NOLINT
|
|
|
|
|
const std::string& host,
|
|
|
|
|
const std::string& port);
|
|
|
|
|
const std::string& host, const std::string& port);
|
|
|
|
|
|
|
|
|
|
void set_timeout_seconds(int timeout_seconds) {
|
|
|
|
|
timeout_seconds_ = timeout_seconds;
|
|
|
|
@ -22,22 +22,19 @@ class AsyncRestClient {
|
|
|
|
|
Request(kHttpGet, url, "", response_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Post(const std::string& url,
|
|
|
|
|
const std::string& content,
|
|
|
|
|
void Post(const std::string& url, std::string&& content,
|
|
|
|
|
HttpResponseHandler response_handler) {
|
|
|
|
|
Request(kHttpPost, url, content, response_handler);
|
|
|
|
|
Request(kHttpPost, url, std::move(content), response_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Put(const std::string& url,
|
|
|
|
|
const std::string& content,
|
|
|
|
|
void Put(const std::string& url, std::string&& content,
|
|
|
|
|
HttpResponseHandler response_handler) {
|
|
|
|
|
Request(kHttpPut, url, content, response_handler);
|
|
|
|
|
Request(kHttpPut, url, std::move(content), response_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Patch(const std::string& url,
|
|
|
|
|
const std::string& content,
|
|
|
|
|
void Patch(const std::string& url, std::string&& content,
|
|
|
|
|
HttpResponseHandler response_handler) {
|
|
|
|
|
Request(kHttpPatch, url, content, response_handler);
|
|
|
|
|
Request(kHttpPatch, url, std::move(content), response_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Delete(const std::string& url,
|
|
|
|
@ -46,10 +43,8 @@ class AsyncRestClient {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void Request(const std::string& method,
|
|
|
|
|
const std::string& url,
|
|
|
|
|
const std::string& content,
|
|
|
|
|
HttpResponseHandler response_handler);
|
|
|
|
|
void Request(const std::string& method, const std::string& url,
|
|
|
|
|
std::string&& content, HttpResponseHandler response_handler);
|
|
|
|
|
|
|
|
|
|
boost::asio::io_context& io_context_;
|
|
|
|
|
|
|
|
|
|