Initial Commit
This commit is contained in:
22
src/routes/pages/mod.rs
Normal file
22
src/routes/pages/mod.rs
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user