diff options
author | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-02-13 17:51:51 +0000 |
---|---|---|
committer | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-02-13 17:51:51 +0000 |
commit | d410b27e85ffa653a64d10bcd6b43cc5f64fe5d9 (patch) | |
tree | 50bed1bf017347115b70db35c5034ae46695f182 /src/config.rs | |
parent | Fixed Clippy warnings (diff) | |
download | miniserve-d410b27e85ffa653a64d10bcd6b43cc5f64fe5d9.tar.gz miniserve-d410b27e85ffa653a64d10bcd6b43cc5f64fe5d9.zip |
Removed config.rs and put back actix config in main.rs
Diffstat (limited to '')
-rw-r--r-- | src/config.rs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/config.rs b/src/config.rs deleted file mode 100644 index 4c345ba..0000000 --- a/src/config.rs +++ /dev/null @@ -1,57 +0,0 @@ -use actix_web::{fs, App}; -use std::net::IpAddr; - -use crate::auth; -use crate::listing; - -#[derive(Clone, Debug)] -pub struct MiniserveConfig { - pub verbose: bool, - pub path: std::path::PathBuf, - pub port: u16, - pub interfaces: Vec<IpAddr>, - pub auth: Option<auth::BasicAuthParams>, - pub path_explicitly_chosen: bool, - pub no_symlinks: bool, - pub random_route: Option<String>, - pub sort_method: listing::SortingMethods, - pub reverse_sort: bool, -} - -pub fn configure_app(app: App<MiniserveConfig>) -> App<MiniserveConfig> { - let s = { - let path = &app.state().path; - let no_symlinks = app.state().no_symlinks; - let random_route = app.state().random_route.clone(); - let sort_method = app.state().sort_method; - let reverse_sort = app.state().reverse_sort; - if path.is_file() { - None - } else { - Some( - fs::StaticFiles::new(path) - .expect("Couldn't create path") - .show_files_listing() - .files_listing_renderer(move |dir, req| { - listing::directory_listing( - dir, - req, - no_symlinks, - random_route.clone(), - sort_method, - reverse_sort, - ) - }), - ) - } - }; - - let random_route = app.state().random_route.clone().unwrap_or_default(); - let full_route = format!("/{}", random_route); - - if let Some(s) = s { - app.handler(&full_route, s) - } else { - app.resource(&full_route, |r| r.f(listing::file_handler)) - } -} |