botui/src/shared/state.rs

29 lines
534 B
Rust
Raw Normal View History

use botlib::http_client::BotServerClient;
2025-12-03 18:42:22 -03:00
use std::sync::Arc;
2025-12-21 23:40:44 -03:00
#[derive(Clone, Debug)]
2025-12-03 18:42:22 -03:00
pub struct AppState {
pub client: Arc<BotServerClient>,
2025-12-03 18:42:22 -03:00
}
impl AppState {
2025-12-21 23:40:44 -03:00
#[must_use]
2025-12-03 18:42:22 -03:00
pub fn new() -> Self {
let url = std::env::var("BOTSERVER_URL").ok();
2025-12-03 18:42:22 -03:00
Self {
client: Arc::new(BotServerClient::new(url)),
2025-12-03 18:42:22 -03:00
}
}
pub async fn health_check(&self) -> bool {
self.client.health_check().await
}
2025-12-03 18:42:22 -03:00
}
impl Default for AppState {
fn default() -> Self {
Self::new()
}
}