aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Flanagan <eli@typedspace.com>2019-09-12 23:57:21 +0000
committerEli Flanagan <eli@typedspace.com>2019-09-12 23:57:21 +0000
commitb3f170e7edf77e6a37f11af8701d427a9b2fe204 (patch)
tree93270e8f2f4232a3d825b952550113543bce28bd
parentuse actix-web method for static index (diff)
downloadminiserve-b3f170e7edf77e6a37f11af8701d427a9b2fe204.tar.gz
miniserve-b3f170e7edf77e6a37f11af8701d427a9b2fe204.zip
change to path option for configurability
Diffstat (limited to '')
-rw-r--r--src/args.rs8
-rw-r--r--src/main.rs8
2 files changed, 8 insertions, 8 deletions
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<PathBuf>,
- /// 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<PathBuf>,
/// 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<std::path::PathBuf>,
/// Enable file upload
pub file_upload: bool,
@@ -237,11 +237,11 @@ fn configure_app(app: App<MiniserveConfig>) -> App<MiniserveConfig> {
};
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();