Skip to content

Commit

Permalink
miro refactor and lock bump
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Oct 20, 2023
1 parent 502413a commit 196df9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions martin/src/srv/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,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

0 comments on commit 196df9e

Please sign in to comment.