Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions source/river/assets/test-config.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
1 change: 1 addition & 0 deletions source/river/src/config/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub struct PathControl {
#[derive(Debug, Clone)]
pub struct FileServerConfig {
pub(crate) name: String,
pub(crate) index_file: Vec<String>,
pub(crate) listeners: Vec<ListenerConfig>,
pub(crate) base_path: Option<PathBuf>,
}
Expand Down
12 changes: 12 additions & 0 deletions source/river/src/config/kdl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
3 changes: 3 additions & 0 deletions source/river/src/config/kdl/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ fn load_test() {
},
],
base_path: Some(".".into()),
index_file: vec!["index.html".to_string()],
}],
daemonize: false,
pid_file: Some("/tmp/river.pidfile".into()),
Expand Down Expand Up @@ -209,10 +210,12 @@ fn load_test() {
name,
listeners,
base_path,
index_file,
} = afs;
assert_eq!(*name, efs.name);
assert_eq!(*listeners, efs.listeners);
assert_eq!(*base_path, efs.base_path);
assert_eq!(*index_file, efs.index_file);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/river/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down