From 9b59aee1211517812d353afe6b9777c7fee81215 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 20 Oct 2023 14:27:21 -0400 Subject: [PATCH] updates --- martin/src/srv/server.rs | 15 ++++++++------- martin/tests/mb_server_test.rs | 2 ++ martin/tests/pg_server_test.rs | 1 + martin/tests/pmt_server_test.rs | 2 ++ tests/expected/auto/catalog_auto.json | 3 ++- tests/expected/configured/catalog_cfg.json | 3 ++- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/martin/src/srv/server.rs b/martin/src/srv/server.rs index f22304276..3e0681b9a 100755 --- a/martin/src/srv/server.rs +++ b/martin/src/srv/server.rs @@ -198,19 +198,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}}") diff --git a/martin/tests/mb_server_test.rs b/martin/tests/mb_server_test.rs index 31f3177ef..046920f24 100644 --- a/martin/tests/mb_server_test.rs +++ b/martin/tests/mb_server_test.rs @@ -69,6 +69,7 @@ async fn mbt_get_catalog() { content_type: image/webp name: ne2sr sprites: {} + fonts: {} "###); } @@ -100,6 +101,7 @@ async fn mbt_get_catalog_gzip() { content_type: image/webp name: ne2sr sprites: {} + fonts: {} "###); } diff --git a/martin/tests/pg_server_test.rs b/martin/tests/pg_server_test.rs index c814f554d..589025d54 100644 --- a/martin/tests/pg_server_test.rs +++ b/martin/tests/pg_server_test.rs @@ -115,6 +115,7 @@ postgres: content_type: application/x-protobuf description: public.table_source_multiple_geom.geom2 sprites: {} + fonts: {} "###); } diff --git a/martin/tests/pmt_server_test.rs b/martin/tests/pmt_server_test.rs index 3ed778313..b9f89628d 100644 --- a/martin/tests/pmt_server_test.rs +++ b/martin/tests/pmt_server_test.rs @@ -54,6 +54,7 @@ async fn pmt_get_catalog() { stamen_toner__raster_CC-BY-ODbL_z3: content_type: image/png sprites: {} + fonts: {} "###); } @@ -72,6 +73,7 @@ async fn pmt_get_catalog_gzip() { p_png: content_type: image/png sprites: {} + fonts: {} "###); } diff --git a/tests/expected/auto/catalog_auto.json b/tests/expected/auto/catalog_auto.json index 3ce4162f5..59082de5e 100644 --- a/tests/expected/auto/catalog_auto.json +++ b/tests/expected/auto/catalog_auto.json @@ -163,5 +163,6 @@ "description": "Major cities from Natural Earth data" } }, - "sprites": {} + "sprites": {}, + "fonts": {} } diff --git a/tests/expected/configured/catalog_cfg.json b/tests/expected/configured/catalog_cfg.json index 2fb48ab5d..b6cee7284 100644 --- a/tests/expected/configured/catalog_cfg.json +++ b/tests/expected/configured/catalog_cfg.json @@ -53,5 +53,6 @@ "sub/circle" ] } - } + }, + "fonts": {} }