chore: allow unused http_get (#674)

* chore: allow unused http_get

* Update ethers-contract/ethers-contract-abigen/src/util.rs

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>

* chore: update cfgs

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Matthias Seitz 2021-12-11 10:37:18 +01:00 committed by GitHub
parent 0e133e4a87
commit 0769174b40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,6 @@ use ethers_core::types::Address;
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use cfg_if::cfg_if;
use inflector::Inflector; use inflector::Inflector;
use proc_macro2::{Ident, Literal, Span, TokenStream}; use proc_macro2::{Ident, Literal, Span, TokenStream};
use quote::quote; use quote::quote;
@ -84,12 +83,13 @@ where
} }
/// Perform an HTTP GET request and return the contents of the response. /// Perform an HTTP GET request and return the contents of the response.
#[cfg(not(target_arch = "wasm32"))]
pub fn http_get(_url: &str) -> Result<String> { pub fn http_get(_url: &str) -> Result<String> {
cfg_if! { cfg_if::cfg_if! {
if #[cfg(any(target_arch = "wasm32", not(feature = "reqwest")))]{ if #[cfg(feature = "reqwest")]{
Err(anyhow!("HTTP is unsupported"))
} else {
Ok(reqwest::blocking::get(_url)?.text()?) Ok(reqwest::blocking::get(_url)?.text()?)
} else {
Err(anyhow!("HTTP is unsupported"))
} }
} }
} }