From 0a4b5dd62c62c443cd203b01fc75a1044dbd1995 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Thu, 19 May 2022 18:25:18 +0530 Subject: [PATCH] feat: setup file listing for download --- Cargo.lock | 36 ++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 2 ++ 3 files changed, 39 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 4d00b48..3723cf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,6 +19,29 @@ dependencies = [ "tokio-util 0.7.1", ] +[[package]] +name = "actix-files" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d81bde9a79336aa51ebed236e91fc1a0528ff67cfdf4f68ca4c61ede9fd26fb5" +dependencies = [ + "actix-http", + "actix-service", + "actix-utils", + "actix-web", + "askama_escape", + "bitflags", + "bytes", + "derive_more", + "futures-core", + "http-range", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", +] + [[package]] name = "actix-http" version = "3.0.4" @@ -284,6 +307,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "askama_escape" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" + [[package]] name = "async-compression" version = "0.3.12" @@ -1269,6 +1298,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-range" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" + [[package]] name = "httparse" version = "1.7.1" @@ -2757,6 +2792,7 @@ dependencies = [ name = "starchart" version = "0.1.0" dependencies = [ + "actix-files", "actix-identity", "actix-rt", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index ac92d1a..4314e4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ members = [ actix-rt = "2.7" actix-web = "4.0.1" actix-identity = "0.4.0" +actix-files = "0.6.0" async-trait = "0.1.51" config = "0.13.0" lazy_static = "1.4.0" diff --git a/src/main.rs b/src/main.rs index 18716bd..8e8ce07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ */ use std::sync::Arc; +use actix_files::Files; use actix_web::{middleware, web::Data, App, HttpServer}; use lazy_static::lazy_static; @@ -81,6 +82,7 @@ async fn main() { middleware::DefaultHeaders::new().add(("Permissions-Policy", "interest-cohort=()")), ) .configure(routes::services) + .service(Files::new("/federate", &settings.repository.root).show_files_listing()) }) .bind(&socket_addr) .unwrap()