use crate::{ClientRequest, ClientResponse, HttpClientError};
pub trait HttpClient: Send + Sync {
fn send(
&self,
request: ClientRequest,
) -> impl std::future::Future<Output = Result<ClientResponse, HttpClientError>> + Send;
fn get(
&self,
url: impl Into<String> + Send,
) -> impl std::future::Future<Output = Result<ClientResponse, HttpClientError>> + Send {
async move { self.send(ClientRequest::get(url)).await }
}
fn post(
&self,
url: impl Into<String> + Send,
body: impl Into<Vec<u8>> + Send,
) -> impl std::future::Future<Output = Result<ClientResponse, HttpClientError>> + Send {
async move { self.send(ClientRequest::post(url).body(body)).await }
}
}