From b3f170e7edf77e6a37f11af8701d427a9b2fe204 Mon Sep 17 00:00:00 2001 From: Eli Flanagan Date: Thu, 12 Sep 2019 19:57:21 -0400 Subject: change to path option for configurability --- src/args.rs | 8 ++++---- src/main.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/args.rs b/src/args.rs index 6a3a4a5..d31cb26 100644 --- a/src/args.rs +++ b/src/args.rs @@ -27,9 +27,9 @@ struct CLIArgs { #[structopt(name = "PATH", parse(from_os_str))] path: Option, - /// serve index.* files by default - #[structopt(short = "d", long)] - default_index: bool, + /// name of an index files to serve by default + #[structopt(long, parse(from_os_str), name="index_file")] + index: Option, /// Port to use #[structopt(short = "p", long = "port", default_value = "8080")] @@ -166,7 +166,7 @@ pub fn parse_args() -> crate::MiniserveConfig { no_symlinks: args.no_symlinks, random_route, default_color_scheme, - default_index: args.default_index, + index: args.index, overwrite_files: args.overwrite_files, file_upload: args.file_upload, } diff --git a/src/main.rs b/src/main.rs index f2dd351..5db9b31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,8 +52,8 @@ pub struct MiniserveConfig { /// Default color scheme pub default_color_scheme: themes::ColorScheme, - /// Serve index.* files by default - pub default_index: bool, + /// name of an index files to serve by default + pub index: Option, /// Enable file upload pub file_upload: bool, @@ -237,11 +237,11 @@ fn configure_app(app: App) -> App { }; if path.is_file() { None - } else if app.state().default_index == true { + } else if let Some(index_file) = &app.state().index { Some( fs::StaticFiles::new(path) .expect("Failed to setup static file handler") - .index_file("index.html") + .index_file(index_file.to_string_lossy()) ) } else { let u_r = upload_route.clone(); -- cgit v1.2.3