update Config.toml
This commit is contained in:
24
Cargo.lock
generated
24
Cargo.lock
generated
@@ -1596,6 +1596,18 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "storage"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-web",
|
||||
"bytes",
|
||||
"rust-s3",
|
||||
"serde",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.5.0"
|
||||
@@ -1963,18 +1975,6 @@ dependencies = [
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-web",
|
||||
"bytes",
|
||||
"rust-s3",
|
||||
"serde",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.67"
|
||||
|
13
src/main.rs
13
src/main.rs
@@ -23,7 +23,6 @@ fn json_response(status_code: u16) -> CustomizeResponder<Json<Response>> {
|
||||
let message = match status_code {
|
||||
200 => { "Success!" }
|
||||
201 => { "Create success!" }
|
||||
204 => { "Delete success!" }
|
||||
205 => { "Update success!" }
|
||||
404 => { "Not exists!" }
|
||||
409 => { "Resource conflict!" }
|
||||
@@ -55,10 +54,12 @@ fn bytes_response(file_content: Bytes, mut file_type: String) -> CustomizeRespon
|
||||
}
|
||||
|
||||
async fn get_minio() -> MinioPrivate {
|
||||
|
||||
let region = env::var("MINIO_REGION").expect("minio region field not exists!");
|
||||
let endpoint = env::var("MINIO_ENDPOINT").expect("minio endpoint field not exists!");
|
||||
let access_key = env::var("MINIO_ACCESS_KEY").expect("minio access key field not exists!");
|
||||
let secret_key = env::var("MINIO_SECRET_KEY").expect("minio secret key field not exists!");
|
||||
|
||||
return MinioPrivate {
|
||||
region,
|
||||
endpoint,
|
||||
@@ -113,7 +114,15 @@ async fn delete_file(path: web::Path<(String, String)>) -> impl Responder {
|
||||
let work_dir = path_parameters.0;
|
||||
let path_name = path_parameters.1;
|
||||
let status_code = minio.delete(work_dir.as_str(), path_name.as_str()).await;
|
||||
json_response(status_code)
|
||||
if status_code == 204 {
|
||||
Bytes::from_static(b"").customize()
|
||||
.with_status(StatusCode::from_u16(204).unwrap())
|
||||
}else {
|
||||
Bytes::from_static(b"{\"error_code\": 404,\"error_message\": \"Not exists!\"}").customize()
|
||||
.with_status(StatusCode::from_u16(404).unwrap())
|
||||
.insert_header(("content-type", "application/json"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
|
Reference in New Issue
Block a user