diff --git a/source/river/assets/test-config.kdl b/source/river/assets/test-config.kdl index d6e1e2c..81f8674 100644 --- a/source/river/assets/test-config.kdl +++ b/source/river/assets/test-config.kdl @@ -129,6 +129,10 @@ services { // // All files within the root will be available base-path "." + // Redirect to an index file on URI like "/" GET, can include multiple options + // + // This is optional. + index-file "index.html" } } } diff --git a/source/river/src/config/internal.rs b/source/river/src/config/internal.rs index db96c94..65124be 100644 --- a/source/river/src/config/internal.rs +++ b/source/river/src/config/internal.rs @@ -135,6 +135,7 @@ pub struct PathControl { #[derive(Debug, Clone)] pub struct FileServerConfig { pub(crate) name: String, + pub(crate) index_file: Vec, pub(crate) listeners: Vec, pub(crate) base_path: Option, } diff --git a/source/river/src/config/kdl/mod.rs b/source/river/src/config/kdl/mod.rs index 68b8ea2..05bcec0 100644 --- a/source/river/src/config/kdl/mod.rs +++ b/source/river/src/config/kdl/mod.rs @@ -222,10 +222,22 @@ fn extract_file_server( None }; + // Index File + // + let index_file = if let Some((ifnode, ifargs)) = map.get("index-file") { + ifargs + .iter() + .filter_map(|arg| arg.value().as_string().map(ToOwned::to_owned)) + .collect() + } else { + vec![] + }; + Ok(FileServerConfig { name: name.to_string(), listeners: list_cfgs, base_path, + index_file, }) } diff --git a/source/river/src/files.rs b/source/river/src/files.rs index 689df92..32d6e54 100644 --- a/source/river/src/files.rs +++ b/source/river/src/files.rs @@ -18,7 +18,7 @@ pub fn river_file_server( let fsconf = StaticFilesConf { root: conf.base_path, canonicalize_uri: true, - index_file: Vec::new().into(), + index_file: conf.index_file.into(), page_404: None, precompressed: Vec::new().into(), ..Default::default()