Building a POST with the chainable setters, finished by the verb.
Building a POST with the chainable setters, finished by the verb.
#include <asio.hpp>
#include <chrono>
#include <iostream>
int main() {
asio::io_context io;
http.
request(
"https://postman-echo.com/post")
.
headers({
"content-type: application/json"})
.body(R"({"greeting": "hello cofetch"})")
if (ec) {
std::cerr << "transport error: " << ec.message() << "\n";
return;
}
});
io.run();
}
RequestBuilder & headers(std::vector< std::string > h)
Definition cofetch.h:350
auto post(CompletionToken &&token)
Definition cofetch.h:377
RequestBuilder & timeout(std::chrono::milliseconds t)
Definition cofetch.h:358
RequestBuilder request(std::string url)
Start a fluent request chain: request(url).body(...).post(token).
Definition cofetch.h:412
long http_code_
Definition cofetch.h:176
std::string data_
Definition cofetch.h:177