Add system information

This commit is contained in:
2024-05-03 21:24:43 +02:00
parent 2fefdb97be
commit 9407d8f0a8
4 changed files with 58 additions and 2 deletions

View File

@ -7,6 +7,7 @@ use std::io::ErrorKind;
pub mod auth_controller;
pub mod server_controller;
pub mod sys_info_controller;
pub mod vm_controller;
/// Custom error to ease controller writing

View File

@ -0,0 +1,22 @@
use crate::controllers::HttpResult;
use crate::virtweb_client;
use actix_web::HttpResponse;
#[derive(serde::Serialize)]
struct SysInfoStatus {
allowed: bool,
}
/// Check if system info can be retrieved
pub async fn config() -> HttpResult {
let info = virtweb_client::get_token_info().await?;
Ok(HttpResponse::Ok().json(SysInfoStatus {
allowed: info.can_retrieve_system_info(),
}))
}
/// Get current system status
pub async fn status() -> HttpResult {
Ok(HttpResponse::Ok().json(virtweb_client::get_server_info().await?))
}