diff --git a/crates/ptth_file_server_bin/src/main.rs b/crates/ptth_file_server_bin/src/main.rs index 32a25cb..4363bc3 100644 --- a/crates/ptth_file_server_bin/src/main.rs +++ b/crates/ptth_file_server_bin/src/main.rs @@ -58,6 +58,7 @@ async fn handle_all (req: Request , state: Arc ) let ptth_resp = file_server::serve_all ( &state.handlebars, &state.metrics_startup, + &**state.metrics_gauge.load (), file_server_root, ptth_req.method, &ptth_req.uri, diff --git a/crates/ptth_server/src/file_server/html.rs b/crates/ptth_server/src/file_server/html.rs index 325cb30..9c2a58a 100644 --- a/crates/ptth_server/src/file_server/html.rs +++ b/crates/ptth_server/src/file_server/html.rs @@ -47,10 +47,22 @@ struct DirEntry { pub async fn serve_root ( handlebars: &Handlebars <'static>, - instance_metrics: &metrics::Startup + metrics_startup: &metrics::Startup, + metrics_gauges: &Option , ) -> Result { - let s = handlebars.render ("file_server_root", &instance_metrics)?; + #[derive (Serialize)] + struct RootHtml <'a> { + metrics_startup: &'a metrics::Startup, + metrics_gauges: &'a Option , + } + + let params = RootHtml { + metrics_startup, + metrics_gauges, + }; + + let s = handlebars.render ("file_server_root", ¶ms)?; Ok (serve_html (s)) } diff --git a/crates/ptth_server/src/file_server/mod.rs b/crates/ptth_server/src/file_server/mod.rs index 8d0934a..f8d45e4 100644 --- a/crates/ptth_server/src/file_server/mod.rs +++ b/crates/ptth_server/src/file_server/mod.rs @@ -219,6 +219,7 @@ async fn serve_file ( pub async fn serve_all ( handlebars: &Handlebars <'static>, metrics_startup: &metrics::Startup, + metrics_gauges: &Option , root: &Path, method: Method, uri: &str, @@ -264,7 +265,7 @@ pub async fn serve_all ( }, InvalidQuery => serve_error (StatusCode::BadRequest, "Query is invalid for this object\n"), - Root => html::serve_root (handlebars, metrics_startup).await?, + Root => html::serve_root (handlebars, metrics_startup, metrics_gauges).await?, ServeDir (internal::ServeDirParams { path, dir, diff --git a/crates/ptth_server/src/lib.rs b/crates/ptth_server/src/lib.rs index 3901dd5..5646498 100644 --- a/crates/ptth_server/src/lib.rs +++ b/crates/ptth_server/src/lib.rs @@ -76,6 +76,7 @@ async fn handle_one_req ( let response = file_server::serve_all ( &state.file_server.handlebars, &state.file_server.metrics_startup, + &**state.file_server.metrics_gauge.load (), file_server_root, parts.method, &parts.uri, diff --git a/handlebars/server/file_server_root.html b/handlebars/server/file_server_root.html index a234e11..e852ecc 100644 --- a/handlebars/server/file_server_root.html +++ b/handlebars/server/file_server_root.html @@ -16,10 +16,16 @@ background-color: #ddd; } -{{server_name}} +{{metrics_startup.server_name}} +

{{metrics_startup.server_name}}

+ +

Gauges

+ +

RSS MiB: {{metrics_gauges.rss_mib}}

+