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 anyhow::{anyhow, Result};
use cfg_if::cfg_if;
use inflector::Inflector;
use proc_macro2::{Ident, Literal, Span, TokenStream};
use quote::quote;
@ -84,12 +83,13 @@ where
}
/// 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> {
cfg_if! {
if #[cfg(any(target_arch = "wasm32", not(feature = "reqwest")))]{
Err(anyhow!("HTTP is unsupported"))
} else {
cfg_if::cfg_if! {
if #[cfg(feature = "reqwest")]{
Ok(reqwest::blocking::get(_url)?.text()?)
} else {
Err(anyhow!("HTTP is unsupported"))
}
}
}