pub trait HttpClient: Send + Default {
type Error;
// Required methods
fn get(
&self,
url: String,
headers: &Headers,
payload: &Query,
) -> impl Future<Output = Result<String, Self::Error>> + Send;
fn post(
&self,
url: String,
headers: &Headers,
payload: &Query,
) -> impl Future<Output = Result<String, Self::Error>> + Send;
}
Expand description
A trait that can be implemented for any HTTP client library in Rust so we can use any library easily.
Required Associated Types§
Required Methods§
fn get( &self, url: String, headers: &Headers, payload: &Query, ) -> impl Future<Output = Result<String, Self::Error>> + Send
fn post( &self, url: String, headers: &Headers, payload: &Query, ) -> impl Future<Output = Result<String, Self::Error>> + Send
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl HttpClient for ReqwestClient
impl HttpClient for ReqwestClient
Implements all functions of HttpClient for reqwest
type Error = ReqwestError
Source§impl HttpClient for TestClient
impl HttpClient for TestClient
Implements a test HTTP client Should just log request data at debug level