Refactor: Rm global var helpers::CLIENT

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-10 18:07:07 +10:00
parent 3c06c45792
commit fa63dbe5cf
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
6 changed files with 42 additions and 36 deletions

View file

@ -205,7 +205,7 @@ async fn entry() -> Result<()> {
};
// Initialize reqwest client
initialize_reqwest_client(opts.secure, opts.min_tls_version.map(|v| v.into()))?;
let client = create_reqwest_client(opts.secure, opts.min_tls_version.map(|v| v.into()))?;
// Setup logging
let mut log_config = ConfigBuilder::new();
@ -244,7 +244,7 @@ async fn entry() -> Result<()> {
// TODO: support git-based fetches (whole repo name rather than just crate name)
let manifest = match opts.manifest_path.clone() {
Some(manifest_path) => load_manifest_path(manifest_path.join("Cargo.toml"))?,
None => fetch_crate_cratesio(&opts.name, &opts.version).await?,
None => fetch_crate_cratesio(&client, &opts.name, &opts.version).await?,
};
let package = manifest.package.unwrap();
@ -298,8 +298,8 @@ async fn entry() -> Result<()> {
meta: target_meta,
};
fetchers.add(GhCrateMeta::new(&fetcher_data).await);
fetchers.add(QuickInstall::new(&fetcher_data).await);
fetchers.add(GhCrateMeta::new(&client, &fetcher_data).await);
fetchers.add(QuickInstall::new(&client, &fetcher_data).await);
}
match fetchers.first_available().await {