update dump route
-use actix_web::HttpResponse;
-use actix_web::{get, post, web};
use log::debug;
+use actix_web::{web, HttpResponse};
use serde::{Deserialize, Serialize};
use crate::error::ResponseError;
-use crate::helpers::Authentication;
+use crate::extractors::authentication::{policies::*, GuardedData};
use crate::Data;
pub fn services(cfg: &mut web::ServiceConfig) {
- cfg.service(create_dump).service(get_dump_status);
+ cfg.route("/dumps", web::post().to(create_dump))
+ .route("/dumps/{dump_uid}/status", web::get().to(get_dump_status));
}
-#[post("/dumps", wrap = "Authentication::Private")]
-async fn create_dump(data: web::Data<Data>) -> Result<HttpResponse, ResponseError> {
+async fn create_dump(data: GuardedData<Private, Data>) -> Result<HttpResponse, ResponseError> {
let res = data.create_dump().await?;
debug!("returns: {:?}", res);
@@ -30,9 +29,8 @@ struct DumpParam {
dump_uid: String,
}
-#[get("/dumps/{dump_uid}/status", wrap = "Authentication::Private")]
async fn get_dump_status(
- data: web::Data<Data>,
+ data: GuardedData<Private, Data>,
path: web::Path<DumpParam>,
) -> Result<HttpResponse, ResponseError> {
let res = data.dump_status(path.dump_uid.clone()).await?;
