diff --git a/cloudflare/Cargo.toml b/cloudflare/Cargo.toml index 353752bd..d15946f4 100644 --- a/cloudflare/Cargo.toml +++ b/cloudflare/Cargo.toml @@ -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"] } diff --git a/cloudflare/src/framework/async_api.rs b/cloudflare/src/framework/async_api.rs index ed89938b..000e1edc 100644 --- a/cloudflare/src/framework/async_api.rs +++ b/cloudflare/src/framework/async_api.rs @@ -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; @@ -48,21 +47,20 @@ impl Client { ) -> anyhow::Result { 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()?;