diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2021-10-25 11:07:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 11:07:11 +0000 |
commit | e1c5d470b5fdaff9acad1ad77ad49ffd9ca096da (patch) | |
tree | e9d3e9de0acd1495f07defe916ba3172a6902233 /src/config.rs | |
parent | Merge pull request #621 from svenstaro/dependabot/cargo/reqwest-0.11.6 (diff) | |
parent | Use Path instead of PathBuf for parameter (diff) | |
download | miniserve-e1c5d470b5fdaff9acad1ad77ad49ffd9ca096da.tar.gz miniserve-e1c5d470b5fdaff9acad1ad77ad49ffd9ca096da.zip |
Merge pull request #515 from sinking-point/sinkingpoint/add-spa-index-option-474
Add --spa-index option
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 16 |
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, |