Blocking HTTP transport.
More...
#include <waterlinkedsonar/http_transport.hpp>
|
| virtual | ~HttpTransport ()=default |
| |
| virtual Response | get (const std::string &path)=0 |
| | Issues a GET request to the given path.
|
| |
| virtual Response | post (const std::string &path, const std::string &json_body, std::optional< std::chrono::milliseconds > timeout_override=std::nullopt)=0 |
| | Issues a POST request with a JSON body.
|
| |
Blocking HTTP transport.
Implementations throw HttpError with status_code() == 0 when a request cannot complete; non-2xx statuses are returned, not thrown.
◆ ~HttpTransport()
| virtual waterlinked::sonar::HttpTransport::~HttpTransport |
( |
| ) |
|
|
virtualdefault |
◆ get()
| virtual Response waterlinked::sonar::HttpTransport::get |
( |
const std::string & |
path | ) |
|
|
pure virtual |
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
-
Implemented in waterlinked::sonar::CurlTransport.
◆ post()
| virtual Response waterlinked::sonar::HttpTransport::post |
( |
const std::string & |
path, |
|
|
const std::string & |
json_body, |
|
|
std::optional< std::chrono::milliseconds > |
timeout_override = std::nullopt |
|
) |
| |
|
pure virtual |
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
-
Implemented in waterlinked::sonar::CurlTransport.
The documentation for this class was generated from the following file: