From 425a07eb390a20324f9887361413d6dd876f4834 Mon Sep 17 00:00:00 2001 From: Pirmin Kalberer Date: Tue, 5 Nov 2024 16:32:06 +0100 Subject: [PATCH 1/5] Add support for URL prefix --- bbox-core/src/config.rs | 8 ++++- bbox-core/src/service.rs | 2 +- bbox-core/templates/base.html | 9 +++--- bbox-core/templates/collections.html | 2 +- bbox-feature-server/src/datasource/gpkg.rs | 23 +++++++++---- bbox-feature-server/src/datasource/mod.rs | 15 ++++++--- bbox-feature-server/src/datasource/postgis.rs | 26 +++++++++------ bbox-feature-server/src/endpoints.rs | 15 +++++---- bbox-feature-server/src/inventory.rs | 32 +++++++++++++------ bbox-feature-server/src/service.rs | 11 ++++--- bbox-feature-server/templates/collection.html | 2 +- bbox-feature-server/templates/feature.html | 2 +- bbox-feature-server/templates/features.html | 4 +-- bbox-feature-server/templates/queryables.html | 2 +- bbox-frontend/src/endpoints.rs | 10 +++--- bbox-frontend/templates/index.html | 10 +++--- bbox-frontend/templates/redoc.html | 2 +- bbox-frontend/templates/swaggerui.html | 4 +-- bbox-map-server/src/inventory.rs | 7 ++++ bbox-map-server/src/service.rs | 4 ++- bbox-map-server/src/wms_fcgi_backend.rs | 2 ++ 21 files changed, 124 insertions(+), 68 deletions(-) diff --git a/bbox-core/src/config.rs b/bbox-core/src/config.rs index 1b3c840d..039143bb 100644 --- a/bbox-core/src/config.rs +++ b/bbox-core/src/config.rs @@ -129,7 +129,8 @@ pub struct WebserverCfg { pub server_addr: String, /// Number of parallel web server threads. Defaults to number of available logical CPUs worker_threads: Option, - public_server_url: Option, + /// Public base URL of the server (e.g. `https://bbox.example.com/`) + pub public_server_url: Option, /// Log level (Default: info) pub loglevel: Option, pub tls_cert: Option, @@ -172,6 +173,11 @@ impl CoreServiceCfg { pub fn loglevel(&self) -> Option { self.webserver.as_ref().and_then(|cfg| cfg.loglevel.clone()) } + pub fn public_server_url(&self) -> Option { + self.webserver + .as_ref() + .and_then(|cfg| cfg.public_server_url.clone()) + } } impl Default for WebserverCfg { diff --git a/bbox-core/src/service.rs b/bbox-core/src/service.rs index 5ccf432e..19b7f0d7 100644 --- a/bbox-core/src/service.rs +++ b/bbox-core/src/service.rs @@ -103,7 +103,7 @@ pub struct CoreService { impl CoreService { pub fn add_service(&mut self, svc: &T) { - let api_base = ""; + let api_base = self.web_config.public_server_url.as_deref().unwrap_or(""); self.ogcapi .landing_page_links diff --git a/bbox-core/templates/base.html b/bbox-core/templates/base.html index ce9eaaba..5c516c46 100644 --- a/bbox-core/templates/base.html +++ b/bbox-core/templates/base.html @@ -4,7 +4,8 @@ BBOX - {% block title %}Home{% endblock %} - + + {% block head %} {% endblock %} @@ -29,12 +30,12 @@

{% block content_title %}{% endblock %}