feat: allow customizing index header
This commit is contained in:
parent
db08186911
commit
ec77fe6a99
2 changed files with 8 additions and 6 deletions
|
@ -75,7 +75,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>uppe.rs</h1>
|
||||
<p>keeping track of your infra's up status</p>
|
||||
<p>%%DESCRIPTION%%</p>
|
||||
<hr class="color"/>
|
||||
<small style="display: block" class="rev">now --></small>
|
||||
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -23,6 +23,9 @@ struct Config {
|
|||
/// defined services, singular because makes more sense in toml
|
||||
service: std::collections::BTreeMap<String, Service>,
|
||||
|
||||
/// service description shown in web page
|
||||
description: Option<String>,
|
||||
|
||||
/// how many samples of history to keep
|
||||
//history: usize,
|
||||
|
||||
|
@ -85,9 +88,12 @@ async fn entry(cli: Cli, config: Config, db: Database) -> Result<(), Box<dyn std
|
|||
});
|
||||
}
|
||||
|
||||
let index = include_str!("../index.html")
|
||||
.replacen("%%DESCRIPTION%%", config.description.as_deref().unwrap_or("keeping track of your infra's up status"), 1);
|
||||
|
||||
// build our application with a single route
|
||||
let app = axum::Router::new()
|
||||
.route("/", axum::routing::get(root))
|
||||
.route("/", axum::routing::get(|| async { Html(index) }))
|
||||
.route("/api/status", axum::routing::get(api_status))
|
||||
.route("/api/status/:service", axum::routing::get(api_status_service))
|
||||
.with_state(db);
|
||||
|
@ -134,10 +140,6 @@ impl IntoResponse for ApiError {
|
|||
}
|
||||
}
|
||||
|
||||
async fn root() -> Html<&'static str> {
|
||||
Html(include_str!("../index.html"))
|
||||
}
|
||||
|
||||
use axum::{extract::{Path, Query, State}, response::{Html, IntoResponse}, Json};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
|
|
Loading…
Reference in a new issue