aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorEli Flanagan <eli@typedspace.com>2019-09-08 00:50:15 +0000
committerEli Flanagan <eli@typedspace.com>2019-09-08 00:50:15 +0000
commitd68a874d18e79eecb7f6a4ba941a3494e408322a (patch)
tree17980df06c3d4568166e6087ca7e26bbfa24d04e /src/main.rs
parentadd a default index serving option (diff)
downloadminiserve-d68a874d18e79eecb7f6a4ba941a3494e408322a.tar.gz
miniserve-d68a874d18e79eecb7f6a4ba941a3494e408322a.zip
wire up arguments, index.html serving still broken
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index dc98df0..46c38d1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,6 +7,7 @@ use simplelog::{Config, LevelFilter, TermLogger, TerminalMode};
use std::io::{self, Write};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::thread;
+use std::path::PathBuf;
use std::time::Duration;
use yansi::{Color, Paint};
@@ -52,6 +53,9 @@ pub struct MiniserveConfig {
/// Default color scheme
pub default_color_scheme: themes::ColorScheme,
+ /// Serve index.* files by default
+ pub default_index: bool,
+
/// Enable file upload
pub file_upload: bool,
@@ -234,6 +238,13 @@ fn configure_app(app: App<MiniserveConfig>) -> App<MiniserveConfig> {
};
if path.is_file() {
None
+ } else if app.state().default_index == true {
+ let mut index_path = PathBuf::from(path);
+ index_path.push("index.html");
+ Some(
+ fs::StaticFiles::new(index_path)
+ .expect("Failed to setup static file handler")
+ )
} else {
let u_r = upload_route.clone();
Some(