2023-09-06 16:54:38 +00:00
|
|
|
use crate::actors::libvirt_actor::HypervisorInfo;
|
2023-09-02 08:28:08 +00:00
|
|
|
use crate::app_config::AppConfig;
|
2023-09-05 11:19:25 +00:00
|
|
|
use crate::constants;
|
2023-09-06 16:54:38 +00:00
|
|
|
use crate::controllers::{HttpResult, LibVirtReq};
|
2023-09-02 08:28:08 +00:00
|
|
|
use crate::extractors::local_auth_extractor::LocalAuthEnabled;
|
2023-09-02 06:07:06 +00:00
|
|
|
use actix_web::{HttpResponse, Responder};
|
|
|
|
|
|
|
|
pub async fn root_index() -> impl Responder {
|
|
|
|
HttpResponse::Ok().body("Hello world!")
|
|
|
|
}
|
2023-09-02 08:28:08 +00:00
|
|
|
|
|
|
|
#[derive(serde::Serialize)]
|
|
|
|
struct StaticConfig {
|
|
|
|
local_auth_enabled: bool,
|
|
|
|
oidc_auth_enabled: bool,
|
2023-09-05 11:19:25 +00:00
|
|
|
iso_mimetypes: &'static [&'static str],
|
|
|
|
iso_max_size: usize,
|
2023-09-02 08:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn static_config(local_auth: LocalAuthEnabled) -> impl Responder {
|
|
|
|
HttpResponse::Ok().json(StaticConfig {
|
|
|
|
local_auth_enabled: *local_auth,
|
|
|
|
oidc_auth_enabled: !AppConfig::get().disable_oidc,
|
2023-09-05 11:19:25 +00:00
|
|
|
iso_mimetypes: &constants::ALLOWED_ISO_MIME_TYPES,
|
|
|
|
iso_max_size: constants::ISO_MAX_SIZE,
|
2023-09-02 08:28:08 +00:00
|
|
|
})
|
|
|
|
}
|
2023-09-06 16:54:38 +00:00
|
|
|
|
|
|
|
#[derive(serde::Serialize)]
|
|
|
|
struct ServerInfo {
|
|
|
|
hypervisor: HypervisorInfo,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn server_info(client: LibVirtReq) -> HttpResult {
|
|
|
|
Ok(HttpResponse::Ok().json(ServerInfo {
|
|
|
|
hypervisor: client.get_info().await?,
|
|
|
|
}))
|
|
|
|
}
|