#include <qt_connection.hpp>
|
| | Connection (QNetworkAccessManager &, const std::string &address, const std::map< std::string, std::string > &headerEntries) |
| |
| | Connection (const Connection &)=delete |
| |
| | ~Connection () |
| |
| Connection & | operator= (const Connection &)=delete |
| |
| Response | fetchPage (const std::string &request) override |
| |
| std::unique_ptr< ISseConnection > | subscribe (const std::string &request, EventCallback callback) override |
| | Subscribe to an SSE endpoint.
|
| |
| std::expected< std::string, HttpError > | fetch (const std::string &request) final |
| | Perform a single HTTP request.
|
| |
| std::expected< std::string, HttpError > | fetch (const std::string &request, IPaginationStrategy &strategy) final |
| | Perform requests with automatic pagination.
|
| |
| CancellationToken | fetch (const std::string &request, FetchCallback onSuccess, ErrorCallback onError={}) final |
| | Perform an HTTP GET request asynchronously.
|
| |
| CancellationToken | fetch (const std::string &request, IPaginationStrategy &strategy, BodyCallback onSuccess, ErrorCallback onError={}) final |
| | Perform paginated requests asynchronously.
|
| |
| | BaseConnection (const std::string &address, const std::map< std::string, std::string > &headerEntries) |
| |
| const std::string & | url () const final |
| | return API url
|
| |
| std::expected< Response, HttpError > | fetchResponse (const std::string &url) final |
| | Perform a single HTTP request returning the full response.
|
| |
| std::string | get (const std::string &) final |
| | perform a request to api
|
| |
| virtual | ~IConnection ()=default |
| |
◆ Connection() [1/2]
| cpp_restapi::QtBackend::Connection::Connection |
( |
QNetworkAccessManager & | , |
|
|
const std::string & | address, |
|
|
const std::map< std::string, std::string > & | headerEntries ) |
◆ Connection() [2/2]
| cpp_restapi::QtBackend::Connection::Connection |
( |
const Connection & | | ) |
|
|
delete |
◆ ~Connection()
| cpp_restapi::QtBackend::Connection::~Connection |
( |
| ) |
|
◆ fetch() [1/4]
| std::expected< std::string, HttpError > cpp_restapi::BaseConnection::fetch |
( |
const std::string & | request | ) |
|
|
finalvirtual |
Perform a single HTTP request.
- Parameters
-
| request | relative API path (e.g. "api/v1/disks") |
- Returns
- response body on success, or an HttpError describing the failure
Returns std::unexpected(HttpError) when:
- The server returns a 4xx or 5xx status code
- A network-level failure occurs (statusCode == 0 in the error)
Reimplemented from cpp_restapi::BaseConnection.
◆ fetch() [2/4]
Perform an HTTP GET request asynchronously.
Non-blocking. onSuccess is called with the full response when the request completes successfully; onError is called with an HttpError if the request fails. The callbacks may be invoked from a background thread (non-Qt backends) or from the Qt event-loop thread (Qt backend) — callers must handle thread-safety accordingly.
- Parameters
-
| request | relative API path (e.g. "users/octocat") |
| onSuccess | called with Response{body, headers, statusCode} on success |
| onError | called with an HttpError on failure (optional) |
- Returns
- cancellation token; store it and set to true to suppress callbacks
Reimplemented from cpp_restapi::BaseConnection.
◆ fetch() [3/4]
Perform requests with automatic pagination.
- Parameters
-
| request | relative API path |
| strategy | pagination strategy defining how to discover next page and merge results |
- Returns
- merged response body from all pages on success, or an HttpError on first failure
Reimplemented from cpp_restapi::BaseConnection.
◆ fetch() [4/4]
Perform paginated requests asynchronously.
Non-blocking. Pages are fetched sequentially; once all pages have been collected the merged result is delivered via onSuccess. On any page failure onError is called and fetching stops.
- Parameters
-
| request | relative API path (e.g. "repos/owner/name/issues") |
| strategy | pagination strategy (next-page discovery and merge) |
| onSuccess | called with the merged body string on success |
| onError | called with an HttpError on failure (optional) |
- Returns
- cancellation token
Reimplemented from cpp_restapi::BaseConnection.
◆ fetchAsync()
◆ fetchPage()
| Response cpp_restapi::QtBackend::Connection::fetchPage |
( |
const std::string & | request | ) |
|
|
overridevirtual |
◆ operator=()
◆ subscribe()
| std::unique_ptr< ISseConnection > cpp_restapi::QtBackend::Connection::subscribe |
( |
const std::string & | request, |
|
|
EventCallback | callback ) |
|
overridevirtual |
Subscribe to an SSE endpoint.
- Parameters
-
| request | API endpoint path (e.g. "events" or "api/v1/events") |
| callback | function called for each received SSE event |
- Returns
- SSE connection handle; use its close() method to stop
Implements cpp_restapi::IConnection.
The documentation for this class was generated from the following file: