update dump route

This commit is contained in:
marin postma 2021-06-24 15:06:58 +02:00
parent adf91d286b
commit ce4fb8ce20
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9

View File

@ -1,18 +1,17 @@
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?;