diff options
author | Billy Bradley <billy@yooguru.com> | 2021-05-01 21:36:55 +0000 |
---|---|---|
committer | Billy Bradley <billy@squeno.com> | 2021-10-08 15:53:51 +0000 |
commit | 6dfe4d1c9b08b108ad71945a60ba24256b61ba26 (patch) | |
tree | 01bfd787c85ae17331e00b24d5bdc13d65a823a8 /src/config.rs | |
parent | Merge pull request #613 from svenstaro/dependabot/cargo/assert_fs-1.0.6 (diff) | |
download | miniserve-6dfe4d1c9b08b108ad71945a60ba24256b61ba26.tar.gz miniserve-6dfe4d1c9b08b108ad71945a60ba24256b61ba26.zip |
Add --spa-index option
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, |