Skip to content

Commit

Permalink
package-proxy integration
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Oct 22, 2023
1 parent 08ebdce commit f32d711
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fastn-core/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,17 @@ where
F: FnOnce(String) -> T + Copy,
T: futures::Future<Output = std::result::Result<D, fastn_core::Error>> + Send + 'static,
{
if url[1..].contains("://") || url.starts_with("//") {
f(url).await
let mut url = if url[1..].contains("://") || url.starts_with("//") {
url
} else {
f(format!("https://{}", url)).await
format!("https://{}", url)
};

if let Ok(package_proxy) = std::env::var("FASTN_PACKAGE_PROXY") {
url = format!("{}/proxy/?url={}", package_proxy, url);
}

f(url).await
}

#[tracing::instrument]
Expand Down

0 comments on commit f32d711

Please sign in to comment.