Skip to content

Commit

Permalink
feat: add Http::new for reqwest::Client (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored Apr 5, 2024
1 parent 796308f commit de7f9dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 0 additions & 8 deletions crates/transport-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ pub struct Http<T> {
}

impl<T> Http<T> {
/// Create a new [`Http`] transport.
pub fn new(url: Url) -> Self
where
T: Default,
{
Self { client: Default::default(), url }
}

/// Create a new [`Http`] transport with a custom client.
pub const fn with_client(client: T, url: Url) -> Self {
Self { client, url }
Expand Down
6 changes: 6 additions & 0 deletions crates/transport-http/src/reqwest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ use alloy_transport::{TransportError, TransportErrorKind, TransportFut};
use reqwest::Response;
use std::task;
use tower::Service;
use url::Url;

impl Http<reqwest::Client> {
/// Create a new [`Http`] transport.
pub fn new(url: Url) -> Self {
Self { client: Default::default(), url }
}

/// Make a request.
fn request_reqwest(&self, req: RequestPacket) -> TransportFut<'static> {
let this = self.clone();
Expand Down

0 comments on commit de7f9dd

Please sign in to comment.