Initial Commit

This commit is contained in:
2021-01-31 00:39:30 +01:00
commit 6085860bc6
10 changed files with 2732 additions and 0 deletions

22
src/routes/pages/mod.rs Normal file
View File

@ -0,0 +1,22 @@
use crate::health::HealthState;
use rocket::{get, State};
use std::sync::Arc;
use tokio::task::spawn;
#[get("/")]
pub async fn index(state: State<'_, Arc<HealthState>>) -> String {
{
let state = Arc::clone(state.inner());
spawn(async move {
state.update().await;
});
}
let mut out = String::new();
for (id, status) in &state.health {
out.push_str(&format!("{}: {:?}\n", id, &*status.lock().await));
}
out
}