Ready to build sysinfo route screen

This commit is contained in:
2023-09-08 09:45:41 +02:00
parent bd5ea1fb23
commit f14e8a8e58
7 changed files with 236 additions and 4 deletions

View File

@ -4,6 +4,7 @@ use crate::constants;
use crate::controllers::{HttpResult, LibVirtReq};
use crate::extractors::local_auth_extractor::LocalAuthEnabled;
use actix_web::{HttpResponse, Responder};
use sysinfo::{System, SystemExt};
pub async fn root_index() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
@ -31,10 +32,17 @@ pub async fn static_config(local_auth: LocalAuthEnabled) -> impl Responder {
#[derive(serde::Serialize)]
struct ServerInfo {
hypervisor: HypervisorInfo,
system: System,
}
pub async fn server_info(client: LibVirtReq) -> HttpResult {
let mut system = System::new();
system.refresh_disks_list();
system.refresh_components_list();
system.refresh_all();
Ok(HttpResponse::Ok().json(ServerInfo {
hypervisor: client.get_info().await?,
system,
}))
}