mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-06-16 18:21:56 +08:00
feat: 实现 Redfish API 标准接口;支持通过前端开关控制 Redfish 服务
This commit is contained in:
29
src/web/handlers/config/redfish.rs
Normal file
29
src/web/handlers/config/redfish.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use axum::{extract::State, Json};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::types::{RedfishConfigResponse, RedfishConfigUpdate};
|
||||
|
||||
pub async fn get_redfish_config(State(state): State<Arc<AppState>>) -> Json<RedfishConfigResponse> {
|
||||
Json(RedfishConfigResponse {
|
||||
enabled: state.config.get().redfish.enabled,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn update_redfish_config(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Json(req): Json<RedfishConfigUpdate>,
|
||||
) -> Result<Json<RedfishConfigResponse>> {
|
||||
state
|
||||
.config
|
||||
.update(|config| {
|
||||
req.apply_to(&mut config.redfish);
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(Json(RedfishConfigResponse {
|
||||
enabled: state.config.get().redfish.enabled,
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user