yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::net::IHttpClient Class Referenceabstract

Abstract interface for HTTP client implementations. More...

#include <http_client.h>

Inheritance diagram for yaze::net::IHttpClient:

Public Member Functions

virtual ~IHttpClient ()=default
 
virtual absl::StatusOr< HttpResponseGet (const std::string &url, const Headers &headers={})=0
 Perform an HTTP GET request.
 
virtual absl::StatusOr< HttpResponsePost (const std::string &url, const std::string &body, const Headers &headers={})=0
 Perform an HTTP POST request.
 
virtual absl::StatusOr< HttpResponsePut (const std::string &url, const std::string &body, const Headers &headers={})
 Perform an HTTP PUT request.
 
virtual absl::StatusOr< HttpResponseDelete (const std::string &url, const Headers &headers={})
 Perform an HTTP DELETE request.
 
virtual void SetTimeout (int timeout_seconds)
 Set a timeout for HTTP requests.
 
int GetTimeout () const
 Get the current timeout setting.
 

Protected Attributes

int timeout_seconds_ = 30
 

Detailed Description

Abstract interface for HTTP client implementations.

This interface abstracts HTTP operations to support both native (using cpp-httplib) and WASM (using emscripten fetch) implementations. All methods return absl::Status or absl::StatusOr for consistent error handling.

Definition at line 48 of file http_client.h.

Constructor & Destructor Documentation

◆ ~IHttpClient()

virtual yaze::net::IHttpClient::~IHttpClient ( )
virtualdefault

Member Function Documentation

◆ Get()

virtual absl::StatusOr< HttpResponse > yaze::net::IHttpClient::Get ( const std::string & url,
const Headers & headers = {} )
pure virtual

Perform an HTTP GET request.

Parameters
urlThe URL to request
headersOptional HTTP headers
Returns
HttpResponse or error status

Implemented in yaze::net::HttpLibClient.

◆ Post()

virtual absl::StatusOr< HttpResponse > yaze::net::IHttpClient::Post ( const std::string & url,
const std::string & body,
const Headers & headers = {} )
pure virtual

Perform an HTTP POST request.

Parameters
urlThe URL to post to
bodyThe request body
headersOptional HTTP headers
Returns
HttpResponse or error status

Implemented in yaze::net::HttpLibClient.

◆ Put()

virtual absl::StatusOr< HttpResponse > yaze::net::IHttpClient::Put ( const std::string & url,
const std::string & body,
const Headers & headers = {} )
inlinevirtual

Perform an HTTP PUT request.

Parameters
urlThe URL to put to
bodyThe request body
headersOptional HTTP headers
Returns
HttpResponse or error status

Reimplemented in yaze::net::HttpLibClient.

Definition at line 81 of file http_client.h.

◆ Delete()

virtual absl::StatusOr< HttpResponse > yaze::net::IHttpClient::Delete ( const std::string & url,
const Headers & headers = {} )
inlinevirtual

Perform an HTTP DELETE request.

Parameters
urlThe URL to delete
headersOptional HTTP headers
Returns
HttpResponse or error status

Reimplemented in yaze::net::HttpLibClient.

Definition at line 95 of file http_client.h.

◆ SetTimeout()

virtual void yaze::net::IHttpClient::SetTimeout ( int timeout_seconds)
inlinevirtual

Set a timeout for HTTP requests.

Parameters
timeout_secondsTimeout in seconds

Reimplemented in yaze::net::HttpLibClient.

Definition at line 106 of file http_client.h.

References timeout_seconds_.

Referenced by yaze::net::HttpLibClient::SetTimeout().

◆ GetTimeout()

int yaze::net::IHttpClient::GetTimeout ( ) const
inline

Get the current timeout setting.

Returns
Timeout in seconds

Definition at line 114 of file http_client.h.

References timeout_seconds_.

Member Data Documentation

◆ timeout_seconds_

int yaze::net::IHttpClient::timeout_seconds_ = 30
protected

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