use actix_web::{post, get, web}; use actix_web::HttpResponse; use serde::{Serialize, Deserialize}; use crate::error::ResponseError; use crate::helpers::Authentication; use crate::Data; pub fn services(cfg: &mut web::ServiceConfig) { cfg.service(create_dump) .service(get_dump_status); } #[post("/dumps", wrap = "Authentication::Private")] async fn create_dump( data: web::Data, ) -> Result { let res = data.create_dump().await?; Ok(HttpResponse::Accepted().json(res)) } #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] struct DumpStatusResponse { status: String, } #[derive(Deserialize)] struct DumpParam { dump_uid: String, } #[get("/dumps/{dump_uid}/status", wrap = "Authentication::Private")] async fn get_dump_status( data: web::Data, path: web::Path, ) -> Result { let res = data.dump_status(path.dump_uid.clone()).await?; Ok(HttpResponse::Ok().json(res)) }