From 196df9e8062f0f7a66c78ffd0f15113dd70af78d Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 20 Oct 2023 14:31:43 -0400 Subject: [PATCH] miro refactor and lock bump --- Cargo.lock | 4 ++-- martin/src/srv/server.rs | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 24a144281..0ae418ec7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -665,9 +665,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" dependencies = [ "libc", ] diff --git a/martin/src/srv/server.rs b/martin/src/srv/server.rs index 7dc7ee99f..6630f4270 100755 --- a/martin/src/srv/server.rs +++ b/martin/src/srv/server.rs @@ -160,19 +160,20 @@ async fn git_source_info( sources: Data, ) -> Result { let sources = sources.get_sources(&path.source_ids, None)?.0; - - let tiles_path = req - .headers() - .get("x-rewrite-url") - .and_then(parse_x_rewrite_url) - .unwrap_or_else(|| req.path().to_owned()); - let info = req.connection_info(); + let tiles_path = get_request_path(&req); let tiles_url = get_tiles_url(info.scheme(), info.host(), req.query_string(), &tiles_path)?; Ok(HttpResponse::Ok().json(merge_tilejson(sources, tiles_url))) } +fn get_request_path(req: &HttpRequest) -> String { + req.headers() + .get("x-rewrite-url") + .and_then(parse_x_rewrite_url) + .unwrap_or_else(|| req.path().to_owned()) +} + fn get_tiles_url(scheme: &str, host: &str, query_string: &str, tiles_path: &str) -> Result { let path_and_query = if query_string.is_empty() { format!("{tiles_path}/{{z}}/{{x}}/{{y}}")