The goal of this library was to have a minimal CURL wrapper implementation that allowed users to make HTTP requests through configurable and reusable objects. These configurable requests could be individual HTTP calls that are responsible for interacting with different external RESTful API endpoints or services.
Additionally, basing it on CURL makes keeps it lightweight and fairly straghtforward to extend or modify.
Description | Supported |
---|---|
Query Parameters | ✔️ |
Custom Header | ✔️ |
Custom Timeout | ✔️ |
HTTP Basic Authentication | ✔️ |
Description | Supported |
---|---|
Query Parameters | ✔️ |
Custom Header | ✔️ |
Custom Timeout | ✔️ |
HTTP Basic Authentication | ✔️ |
In Progress
In Progress
In Progress
Getting started is as easy as including easyhttp.hpp
in your source file.
You probably want to create a RequestConfig
object to store all relevant settings for your particular HTTP request:
struct RequestConfig {
std::string url;
UrlParameters params;
Headers headers;
BasicAuthentication auth;
std::chrono::seconds timeout_sec;
};
Explicit construction of a request configuration object showing available settings:
Request req = Request();
RequestConfig config = { "http://postman-echo.com/get", UrlParameters(), Headers(), BasicAuthentication(), std::chrono::seconds(1) };
RequestResponse resp = req.get(config);
std::cout << "Status: " << resp.status << " Content: " << resp.content << "\n";
Implict RequestConfig
object with no settings besides URL and timeout of 3 seconds
Request req = Request();
RequestConfig config = { "http://google.com", {}, {}, {}, std::chrono::seconds(3) };
RequestResponse resp = req.get(config);
RequestConfig
with URL paramaters foo:bar
and timeout of 1 second
RequestConfig r = { "http://postman-echo.com/get", {{"foo","bar"}}, {}, {}, std::chrono::seconds(1)};