mirror of
https://github.com/maplibre/martin.git
synced 2024-12-19 04:41:46 +03:00
dummy rewrite url fix
This commit is contained in:
parent
e187a9ace7
commit
c8d46d398a
@ -3,7 +3,7 @@ use iron::headers::{Headers, parsing};
|
|||||||
use iron::prelude::{Plugin};
|
use iron::prelude::{Plugin};
|
||||||
use mapbox_expressions_to_sql;
|
use mapbox_expressions_to_sql;
|
||||||
use persistent::Read;
|
use persistent::Read;
|
||||||
use regex::Captures;
|
use regex::{Regex, Captures};
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use urlencoded::UrlEncodedQuery;
|
use urlencoded::UrlEncodedQuery;
|
||||||
|
|
||||||
@ -44,15 +44,14 @@ pub fn tileset(req: &mut Request, caps: Captures) -> IronResult<Response> {
|
|||||||
format!("{}:{}", host, port)
|
format!("{}:{}", host, port)
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = req.url.path();
|
let original_url = get_header(&req.headers, "x-rewrite-url", &req.url.path().join("/"));
|
||||||
let uri = if path.len() > 1 {
|
let re = Regex::new(r"\A(.*)\.json\z").unwrap();
|
||||||
path.split_last().map(|(_, elements)| elements.join("/")).unwrap()
|
let uri = match re.captures(&original_url) {
|
||||||
} else {
|
Some(caps) => caps[1].to_string(),
|
||||||
caps["tileset"].to_string()
|
None => return Ok(Response::with((status::InternalServerError)))
|
||||||
};
|
};
|
||||||
|
|
||||||
let original_url = get_header(&req.headers, "x-rewrite-url", &uri);
|
let tiles_url = format!("{}://{}/{}/{{z}}/{{x}}/{{y}}.pbf", protocol, host_and_port, uri);
|
||||||
let tiles_url = format!("{}://{}/{}/{{z}}/{{x}}/{{y}}.pbf", protocol, host_and_port, original_url);
|
|
||||||
|
|
||||||
let mut tilejson_builder = TileJSONBuilder::new();
|
let mut tilejson_builder = TileJSONBuilder::new();
|
||||||
tilejson_builder.scheme("tms");
|
tilejson_builder.scheme("tms");
|
||||||
|
Loading…
Reference in New Issue
Block a user