Move all crates to a top-level crates folder

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Nathan Sobo
2021-10-04 13:22:21 -06:00
co-authored by Max Brunsfeld
parent d768224182
commit fdfed3d7db
282 changed files with 195588 additions and 16 deletions
+26
View File
@@ -0,0 +1,26 @@
pub use anyhow::{anyhow, Result};
use futures::future::BoxFuture;
use std::sync::Arc;
pub use surf::{
http::{Method, Response as ServerResponse},
Request, Response, Url,
};
pub trait HttpClient: Send + Sync {
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response>>;
}
pub fn client() -> Arc<dyn HttpClient> {
Arc::new(surf::client())
}
impl HttpClient for surf::Client {
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response>> {
Box::pin(async move {
Ok(self
.send(req)
.await
.map_err(|e| anyhow!("http request failed: {}", e))?)
})
}
}