Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Oct 20, 2023
1 parent 6139ab5 commit 9b59aee
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
15 changes: 8 additions & 7 deletions martin/src/srv/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,20 @@ async fn git_source_info(
sources: Data<TileSources>,
) -> Result<HttpResponse> {
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<String> {
let path_and_query = if query_string.is_empty() {
format!("{tiles_path}/{{z}}/{{x}}/{{y}}")
Expand Down
2 changes: 2 additions & 0 deletions martin/tests/mb_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async fn mbt_get_catalog() {
content_type: image/webp
name: ne2sr
sprites: {}
fonts: {}
"###);
}

Expand Down Expand Up @@ -100,6 +101,7 @@ async fn mbt_get_catalog_gzip() {
content_type: image/webp
name: ne2sr
sprites: {}
fonts: {}
"###);
}

Expand Down
1 change: 1 addition & 0 deletions martin/tests/pg_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ postgres:
content_type: application/x-protobuf
description: public.table_source_multiple_geom.geom2
sprites: {}
fonts: {}
"###);
}

Expand Down
2 changes: 2 additions & 0 deletions martin/tests/pmt_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async fn pmt_get_catalog() {
stamen_toner__raster_CC-BY-ODbL_z3:
content_type: image/png
sprites: {}
fonts: {}
"###);
}

Expand All @@ -72,6 +73,7 @@ async fn pmt_get_catalog_gzip() {
p_png:
content_type: image/png
sprites: {}
fonts: {}
"###);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/expected/auto/catalog_auto.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,6 @@
"description": "Major cities from Natural Earth data"
}
},
"sprites": {}
"sprites": {},
"fonts": {}
}
3 changes: 2 additions & 1 deletion tests/expected/configured/catalog_cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
"sub/circle"
]
}
}
},
"fonts": {}
}

0 comments on commit 9b59aee

Please sign in to comment.