You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
876 B

pub mod upload {
use crate::{messages::BeginUpload, types::{Path, StorePath}};
use actix::Recipient;
use actix_web::{HttpResponse, post, web::{Data, Json}};
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
pub struct Request {
store_path: StorePath,
nar_hash: String,
nar_size: u32,
references: Vec<Path>,
deriver: Path,
sig: Vec<String>
}
#[derive(Serialize)]
pub enum Response {
Ok {
upload_path: String,
},
AlreadyExists
}
#[post("api_v1/upload")]
pub async fn endpoint(req: Json<Request>, begin_upload: Data<Recipient<BeginUpload>>) -> HttpResponse {
let req = req.into_inner();
match begin_upload.send(BeginUpload {}).await {
Ok(o) => HttpResponse::Ok().json(Response::Ok { upload_path: o.to_string() }),
Err(e) => HttpResponse::Conflict().json(Response::AlreadyExists),
}
}
}