Ready to build sysinfo route screen
This commit is contained in:
@ -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,
|
||||
}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user