mirror of
https://github.com/maplibre/martin.git
synced 2024-12-19 21:01:45 +03:00
fix: handle x-rewrite-url header
This commit is contained in:
parent
fbb5a7b996
commit
63c976e8b9
@ -43,9 +43,23 @@ fn source(req: HttpRequest<State>) -> Result<HttpResponse> {
|
||||
.get("sources")
|
||||
.ok_or(error::ErrorBadRequest("invalid source"))?;
|
||||
|
||||
let path = req.headers()
|
||||
.get("x-rewrite-url")
|
||||
.map_or(String::from(source_ids), |header| {
|
||||
let parts: Vec<&str> = header.to_str().unwrap().split(".").collect();
|
||||
let (_, parts_without_extension) = parts.split_last().unwrap();
|
||||
let path_without_extension = parts_without_extension.join(".");
|
||||
let (_, path_without_leading_slash) = path_without_extension.split_at(1);
|
||||
|
||||
String::from(path_without_leading_slash)
|
||||
});
|
||||
|
||||
let conn = req.connection_info();
|
||||
let tiles_url = format!(
|
||||
"{}/{{z}}/{{x}}/{{y}}.pbf",
|
||||
req.url_for("tilejson", &[source_ids]).unwrap()
|
||||
"{}://{}/{}/{{z}}/{{x}}/{{y}}.pbf",
|
||||
conn.scheme(),
|
||||
conn.host(),
|
||||
path
|
||||
);
|
||||
|
||||
let mut tilejson_builder = TileJSONBuilder::new();
|
||||
|
Loading…
Reference in New Issue
Block a user