diff options
Diffstat (limited to 'cli/tools/registry/api.rs')
-rw-r--r-- | cli/tools/registry/api.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/cli/tools/registry/api.rs b/cli/tools/registry/api.rs index 519800660..ee9579a19 100644 --- a/cli/tools/registry/api.rs +++ b/cli/tools/registry/api.rs @@ -1,9 +1,8 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use crate::http_util; use deno_core::error::AnyError; use deno_core::serde_json; -use deno_runtime::deno_fetch; +use deno_runtime::deno_fetch::reqwest; use lsp_types::Url; use serde::de::DeserializeOwned; @@ -83,7 +82,7 @@ impl std::fmt::Debug for ApiError { impl std::error::Error for ApiError {} pub async fn parse_response<T: DeserializeOwned>( - response: http::Response<deno_fetch::ResBody>, + response: reqwest::Response, ) -> Result<T, ApiError> { let status = response.status(); let x_deno_ray = response @@ -91,7 +90,7 @@ pub async fn parse_response<T: DeserializeOwned>( .get("x-deno-ray") .and_then(|value| value.to_str().ok()) .map(|s| s.to_string()); - let text = http_util::body_to_string(response).await.unwrap(); + let text = response.text().await.unwrap(); if !status.is_success() { match serde_json::from_str::<ApiError>(&text) { @@ -123,9 +122,9 @@ pub async fn get_scope( client: &HttpClient, registry_api_url: &Url, scope: &str, -) -> Result<http::Response<deno_fetch::ResBody>, AnyError> { +) -> Result<reqwest::Response, AnyError> { let scope_url = format!("{}scopes/{}", registry_api_url, scope); - let response = client.get(scope_url.parse()?)?.send().await?; + let response = client.get(&scope_url).send().await?; Ok(response) } @@ -142,9 +141,9 @@ pub async fn get_package( registry_api_url: &Url, scope: &str, package: &str, -) -> Result<http::Response<deno_fetch::ResBody>, AnyError> { +) -> Result<reqwest::Response, AnyError> { let package_url = get_package_api_url(registry_api_url, scope, package); - let response = client.get(package_url.parse()?)?.send().await?; + let response = client.get(&package_url).send().await?; Ok(response) } |