aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index ce4e5d7..e0d5ec5 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -68,6 +68,13 @@ pub struct MiniserveConfig {
/// However, if a directory contains this file, miniserve will serve that file instead.
pub index: Option<std::path::PathBuf>,
+ /// The index file of a single page application
+ ///
+ /// If this option is set, miniserve will serve the specified file instead of a 404 page when
+ /// a non-existent path is requested. This is intended for single-page applications where
+ /// routing takes place on the client side.
+ pub spa_index: Option<std::path::PathBuf>,
+
/// Enable QR code display
pub show_qrcode: bool,
@@ -169,6 +176,12 @@ impl MiniserveConfig {
#[cfg(not(feature = "tls"))]
let tls_rustls_server_config = None;
+ // If spa_index is set but index is unset, copy the former into the latter
+ let index = match args.index {
+ Some(index) => Some(index),
+ None => args.spa_index.clone(),
+ };
+
Ok(MiniserveConfig {
verbose: args.verbose,
path: args.path.unwrap_or_else(|| PathBuf::from(".")),
@@ -183,7 +196,8 @@ impl MiniserveConfig {
css_route,
default_color_scheme,
default_color_scheme_dark,
- index: args.index,
+ index,
+ spa_index: args.spa_index,
overwrite_files: args.overwrite_files,
show_qrcode: args.qrcode,
file_upload: args.file_upload,