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

make NoopClient feature dependant #1380

Merged
Merged
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
27 changes: 15 additions & 12 deletions sdk/core/src/http_client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
#[cfg(not(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls")))]
mod noop;
#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))]
mod reqwest;

#[cfg(not(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls")))]
use self::noop::NoopClient;
#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))]
pub use self::reqwest::*;
pub use noop::*;

use self::reqwest::*;
use crate::error::ErrorKind;
use async_trait::async_trait;
use bytes::Bytes;
use serde::Serialize;
use std::sync::Arc;

/// Construct a new `HttpClient`
pub fn new_http_client() -> Arc<dyn HttpClient> {
#[allow(unused)]
let http_client: Arc<dyn HttpClient> = Arc::new(NoopClient);
#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))]
let http_client = new_reqwest_client();
http_client
{
new_reqwest_client()
}
#[cfg(not(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls")))]
{
Arc::new(NoopClient)
}
}

use crate::error::ErrorKind;
use async_trait::async_trait;
use bytes::Bytes;
use serde::Serialize;

/// An HTTP client which can send requests.
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
Expand Down