From 8336166e0e541f213d0f3b20d55ea509bbb2f2d8 Mon Sep 17 00:00:00 2001 From: devitway Date: Mon, 23 Feb 2026 07:48:20 +0000 Subject: [PATCH] style: apply rustfmt to registry handlers --- nora-registry/src/registry/maven.rs | 6 +++++- nora-registry/src/registry/npm.rs | 10 ++++++++-- nora-registry/src/registry/pypi.rs | 26 ++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/nora-registry/src/registry/maven.rs b/nora-registry/src/registry/maven.rs index 4b062f0..fe155f2 100644 --- a/nora-registry/src/registry/maven.rs +++ b/nora-registry/src/registry/maven.rs @@ -110,7 +110,11 @@ async fn upload( } } -async fn fetch_from_proxy(client: &reqwest::Client, url: &str, timeout_secs: u64) -> Result, ()> { +async fn fetch_from_proxy( + client: &reqwest::Client, + url: &str, + timeout_secs: u64, +) -> Result, ()> { let response = client .get(url) .timeout(Duration::from_secs(timeout_secs)) diff --git a/nora-registry/src/registry/npm.rs b/nora-registry/src/registry/npm.rs index 7982c38..f5d8370 100644 --- a/nora-registry/src/registry/npm.rs +++ b/nora-registry/src/registry/npm.rs @@ -55,7 +55,9 @@ async fn handle_request(State(state): State>, Path(path): Path>, Path(path): Path Result, ()> { +async fn fetch_from_proxy( + client: &reqwest::Client, + url: &str, + timeout_secs: u64, +) -> Result, ()> { let response = client .get(url) .timeout(Duration::from_secs(timeout_secs)) diff --git a/nora-registry/src/registry/pypi.rs b/nora-registry/src/registry/pypi.rs index 406df85..c768485 100644 --- a/nora-registry/src/registry/pypi.rs +++ b/nora-registry/src/registry/pypi.rs @@ -85,7 +85,9 @@ async fn package_versions( if let Some(proxy_url) = &state.config.pypi.proxy { let url = format!("{}/{}/", proxy_url.trim_end_matches('/'), normalized); - if let Ok(html) = fetch_package_page(&state.http_client, &url, state.config.pypi.proxy_timeout).await { + if let Ok(html) = + fetch_package_page(&state.http_client, &url, state.config.pypi.proxy_timeout).await + { // Rewrite URLs in the HTML to point to our registry let rewritten = rewrite_pypi_links(&html, &normalized); return (StatusCode::OK, Html(rewritten)).into_response(); @@ -130,10 +132,22 @@ async fn download_file( // First, fetch the package page to find the actual download URL let page_url = format!("{}/{}/", proxy_url.trim_end_matches('/'), normalized); - if let Ok(html) = fetch_package_page(&state.http_client, &page_url, state.config.pypi.proxy_timeout).await { + if let Ok(html) = fetch_package_page( + &state.http_client, + &page_url, + state.config.pypi.proxy_timeout, + ) + .await + { // Find the URL for this specific file if let Some(file_url) = find_file_url(&html, &filename) { - if let Ok(data) = fetch_file(&state.http_client, &file_url, state.config.pypi.proxy_timeout).await { + if let Ok(data) = fetch_file( + &state.http_client, + &file_url, + state.config.pypi.proxy_timeout, + ) + .await + { state.metrics.record_download("pypi"); state.metrics.record_cache_miss(); state.activity.push(ActivityEntry::new( @@ -177,7 +191,11 @@ fn normalize_name(name: &str) -> String { } /// Fetch package page from upstream -async fn fetch_package_page(client: &reqwest::Client, url: &str, timeout_secs: u64) -> Result { +async fn fetch_package_page( + client: &reqwest::Client, + url: &str, + timeout_secs: u64, +) -> Result { let response = client .get(url) .timeout(Duration::from_secs(timeout_secs))