Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 2 additions & 154 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 5 additions & 17 deletions common/http-api-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,13 @@ license.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["tunneling"]
tunneling = []
axum_test = ["axum-test"]
default=["tunneling"]
tunneling=[]

[dependencies]
async-trait = { workspace = true }
axum-test = { workspace = true, features = ["reqwest"], optional = true }
bincode = { workspace = true }
reqwest = { workspace = true, features = [
"json",
"gzip",
"deflate",
"brotli",
"zstd",
"rustls-tls",
] }
reqwest = { workspace = true, features = ["json", "gzip", "deflate", "brotli", "zstd", "rustls-tls"] }
http.workspace = true
url = { workspace = true }
once_cell = { workspace = true }
Expand All @@ -45,11 +36,7 @@ nym-http-api-common = { path = "../http-api-common", default-features = false }
nym-bin-common = { path = "../bin-common" }

[target."cfg(not(target_arch = \"wasm32\"))".dependencies]
hickory-resolver = { workspace = true, features = [
"https-ring",
"tls-ring",
"webpki-roots",
] }
hickory-resolver = { workspace = true, features = ["https-ring", "tls-ring", "webpki-roots"] }

# for request timeout until https://github.com/seanmonstar/reqwest/issues/1135 is fixed
[target."cfg(target_arch = \"wasm32\")".dependencies.wasmtimer]
Expand All @@ -58,3 +45,4 @@ features = ["tokio"]

[dev-dependencies]
tokio = { workspace = true, features = ["rt", "macros"] }

51 changes: 0 additions & 51 deletions common/http-api-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,57 +809,6 @@ impl ApiClientCore for Client {
}
}

/// An axum test client useful for writing unit tests
#[cfg(feature = "axum_test")]
pub struct AxumTestClient<'a> {
axum_test: &'a axum_test::TestServer,
}

#[cfg(feature = "axum_test")]
impl<'a> AxumTestClient<'a> {
/// Create an instance of AxumTestClient using a axum_test::TestServer
pub fn new(axum_test: &'a axum_test::TestServer) -> Self {
Self { axum_test }
}
}

#[cfg(feature = "axum_test")]
#[async_trait::async_trait]
impl<'a> ApiClientCore for AxumTestClient<'a> {
fn create_request<P, B, K, V>(
&self,
method: reqwest::Method,
path: P,
_params: Params<'_, K, V>,
json_body: Option<&B>,
) -> RequestBuilder
where
P: RequestPath,
B: Serialize + ?Sized,
K: AsRef<str>,
V: AsRef<str>,
{
let segments = path.to_sanitized_segments();
let path = if segments.is_empty() {
String::from("/")
} else {
segments.join("/")
};
let mut req_builder = self.axum_test.reqwest_method(method, &path);
if let Some(json) = json_body {
req_builder = req_builder.json(json);
}
req_builder
}

async fn send<E>(&self, request: RequestBuilder) -> Result<Response, HttpClientError<E>>
where
E: Display,
{
Ok(request.send().await?)
}
}

/// Common usage functionality for the http client.
///
/// These functions allow for cleaner downstream usage free of type parameters and unneeded imports.
Expand Down
Loading