waterlinkedsonar
C++ client library for the Water Linked Sonar 3D-15
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
waterlinked::sonar::HttpTransport Class Referenceabstract

Blocking HTTP transport. More...

#include <waterlinkedsonar/http_transport.hpp>

Inheritance diagram for waterlinked::sonar::HttpTransport:
waterlinked::sonar::CurlTransport

Classes

struct  Response
 

Public Member Functions

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.
 

Detailed Description

Blocking HTTP transport.

Implementations throw HttpError with status_code() == 0 when a request cannot complete; non-2xx statuses are returned, not thrown.

Constructor & Destructor Documentation

◆ ~HttpTransport()

virtual waterlinked::sonar::HttpTransport::~HttpTransport ( )
virtualdefault

Member Function Documentation

◆ get()

virtual Response waterlinked::sonar::HttpTransport::get ( const std::string &  path)
pure virtual

Issues a GET request to the given path.

Parameters
pathRelative path, e.g. "/api/v1/integration/about".
Returns
Status code and response body.
Exceptions
HttpErrorwhen the request cannot complete.

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
pathRelative path.
json_bodyRequest body, sent as application/json.
timeout_overrideReplaces 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
HttpErrorwhen the request cannot complete.

Implemented in waterlinked::sonar::CurlTransport.


The documentation for this class was generated from the following file: