diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs index ce4e5d7..0af19a6 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,9 @@ 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 = args.index.or(args.spa_index.clone()); + Ok(MiniserveConfig { verbose: args.verbose, path: args.path.unwrap_or_else(|| PathBuf::from(".")), @@ -183,7 +193,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, |