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

libcurl easy-interface transport: one handle, blocking, not thread-safe. More...

#include <waterlinkedsonar/curl_transport.hpp>

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

Public Member Functions

 CurlTransport (const std::string &ip, std::uint16_t port, std::chrono::milliseconds timeout)
 Connects to ip on port; each request times out after timeout.
 
 ~CurlTransport () override
 
 CurlTransport (const CurlTransport &)=delete
 
CurlTransportoperator= (const CurlTransport &)=delete
 
Response get (const std::string &path) override
 Issues a GET request to the given path.
 
Response post (const std::string &path, const std::string &json_body, std::optional< std::chrono::milliseconds > timeout_override=std::nullopt) override
 Issues a POST request with a JSON body.
 
- Public Member Functions inherited from waterlinked::sonar::HttpTransport
virtual ~HttpTransport ()=default
 

Detailed Description

libcurl easy-interface transport: one handle, blocking, not thread-safe.

Constructor & Destructor Documentation

◆ 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
HttpErrorwhen the curl handle cannot be created.

◆ ~CurlTransport()

waterlinked::sonar::CurlTransport::~CurlTransport ( )
override

◆ CurlTransport() [2/2]

waterlinked::sonar::CurlTransport::CurlTransport ( const CurlTransport )
delete

Member Function Documentation

◆ get()

Response waterlinked::sonar::CurlTransport::get ( const std::string &  path)
overridevirtual

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.

Implements waterlinked::sonar::HttpTransport.

◆ operator=()

CurlTransport & waterlinked::sonar::CurlTransport::operator= ( const CurlTransport )
delete

◆ 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
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.

Implements waterlinked::sonar::HttpTransport.


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