libcurl easy-interface transport: one handle, blocking, not thread-safe.
More...
#include <waterlinkedsonar/curl_transport.hpp>
libcurl easy-interface transport: one handle, blocking, not thread-safe.
◆ CurlTransport() [1/2]
| waterlinked::sonar::CurlTransport::CurlTransport |
( |
const std::string & |
ip, |
|
|
std::uint16_t |
port, |
|
|
std::chrono::milliseconds |
timeout |
|
) |
| |
Connects to ip on port; each request times out after timeout.
- Exceptions
-
| HttpError | when the curl handle cannot be created. |
◆ ~CurlTransport()
| waterlinked::sonar::CurlTransport::~CurlTransport |
( |
| ) |
|
|
override |
◆ CurlTransport() [2/2]
| waterlinked::sonar::CurlTransport::CurlTransport |
( |
const CurlTransport & |
| ) |
|
|
delete |
◆ get()
| Response waterlinked::sonar::CurlTransport::get |
( |
const std::string & |
path | ) |
|
|
overridevirtual |
Issues a GET request to the given path.
- Parameters
-
| path | Relative path, e.g. "/api/v1/integration/about". |
- Returns
- Status code and response body.
- Exceptions
-
Implements waterlinked::sonar::HttpTransport.
◆ operator=()
◆ post()
| Response waterlinked::sonar::CurlTransport::post |
( |
const std::string & |
path, |
|
|
const std::string & |
json_body, |
|
|
std::optional< std::chrono::milliseconds > |
timeout_override = std::nullopt |
|
) |
| |
|
overridevirtual |
Issues a POST request with a JSON body.
- Parameters
-
| path | Relative path. |
| json_body | Request body, sent as application/json. |
| timeout_override | Replaces the transport's default timeout for this request; needed for endpoints whose server-side work is caller-bounded (NTP force-sync). |
- Returns
- Status code and response body.
- Exceptions
-
Implements waterlinked::sonar::HttpTransport.
The documentation for this class was generated from the following file: