Can define network filters
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use crate::libvirt_client::LibVirtClient;
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::body::BoxBody;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use std::error::Error;
|
||||
@ -32,8 +33,15 @@ impl Display for HttpErr {
|
||||
}
|
||||
|
||||
impl actix_web::error::ResponseError for HttpErr {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
HttpErr::Err(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
HttpErr::HTTPResponse(r) => r.status(),
|
||||
}
|
||||
}
|
||||
fn error_response(&self) -> HttpResponse<BoxBody> {
|
||||
log::error!("Error while processing request! {}", self);
|
||||
|
||||
HttpResponse::InternalServerError().body("Failed to execute request!")
|
||||
}
|
||||
}
|
||||
|
@ -112,10 +112,15 @@ pub async fn update(
|
||||
id: web::Path<SingleVMUUidReq>,
|
||||
req: web::Json<VMInfo>,
|
||||
) -> HttpResult {
|
||||
let mut domain = req.0.as_tomain().map_err(|e| {
|
||||
log::error!("Failed to extract domain info! {e}");
|
||||
HttpResponse::BadRequest().json(format!("Failed to extract domain info! {e}"))
|
||||
})?;
|
||||
let mut domain = match req.0.as_tomain() {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
log::error!("Failed to extract domain info! {e}");
|
||||
return Ok(
|
||||
HttpResponse::BadRequest().json(format!("Failed to extract domain info! {e}"))
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
domain.uuid = Some(id.uid);
|
||||
if let Err(e) = client.update_domain(req.0, domain).await {
|
||||
|
Reference in New Issue
Block a user