Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary cfg-if dep #204

Merged
merged 1 commit into from
Jan 31, 2023
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
1 change: 0 additions & 1 deletion cloudflare/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ anyhow = "1.0"
async-trait = "0.1"
base64 = "0.13"
chrono = { version = "0.4", default-features = false, features = ["serde", "clock", "std", "wasmbind"] }
cfg-if = "1.0"
http = "0.2"
percent-encoding = "2.1.0"
reqwest = { version = "0.11.4", default-features = false, features = ["json", "blocking"] }
Expand Down
28 changes: 13 additions & 15 deletions cloudflare/src/framework/async_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::framework::{
Environment, HttpApiClientConfig,
};
use async_trait::async_trait;
use cfg_if::cfg_if;
use serde::Serialize;
use std::net::SocketAddr;

Expand Down Expand Up @@ -48,21 +47,20 @@ impl Client {
) -> anyhow::Result<Client> {
let mut builder = reqwest::Client::builder().default_headers(config.default_headers);

cfg_if! {
if #[cfg(not(target_arch = "wasm32"))] {
// There is no resolve method in wasm.
if let Some(address) = config.resolve_ip {
let url = url::Url::from(&environment);
builder = builder.resolve(
url.host_str()
.expect("Environment url should have a hostname"),
SocketAddr::new(address, 443),
);
}

// There are no timeouts in wasm. The property is documented as no-op in wasm32.
builder = builder.timeout(config.http_timeout);
#[cfg(not(target_arch = "wasm32"))]
{
// There is no resolve method in wasm.
if let Some(address) = config.resolve_ip {
let url = url::Url::from(&environment);
builder = builder.resolve(
url.host_str()
.expect("Environment url should have a hostname"),
SocketAddr::new(address, 443),
);
}

// There are no timeouts in wasm. The property is documented as no-op in wasm32.
builder = builder.timeout(config.http_timeout);
}

let http_client = builder.build()?;
Expand Down