feat: support render-index/render-spa

closes #5
This commit is contained in:
sigoden
2022-06-01 22:49:55 +08:00
parent 1fe391f9d9
commit 830d3343f4
2 changed files with 100 additions and 30 deletions

View File

@@ -54,6 +54,16 @@ fn app() -> clap::Command<'static> {
.long("allow-symlink")
.help("Allow symlink to directories/files outside root directory"),
)
.arg(
Arg::new("render-index")
.long("render-index")
.help("Render existing index.html when requesting a directory"),
)
.arg(
Arg::new("render-spa")
.long("render-spa")
.help("Render spa, rewrite all not-found requests to `index.html"),
)
.arg(
Arg::new("auth")
.short('a')
@@ -87,6 +97,8 @@ pub struct Args {
pub allow_upload: bool,
pub allow_delete: bool,
pub allow_symlink: bool,
pub render_index: bool,
pub render_spa: bool,
pub cors: bool,
}
@@ -105,6 +117,8 @@ impl Args {
let allow_upload = matches.is_present("allow-all") || matches.is_present("allow-upload");
let allow_delete = matches.is_present("allow-all") || matches.is_present("allow-delete");
let allow_symlink = matches.is_present("allow-all") || matches.is_present("allow-symlink");
let render_index = matches.is_present("render-index");
let render_spa = matches.is_present("render-spa");
Ok(Args {
address,
@@ -116,6 +130,8 @@ impl Args {
allow_delete,
allow_upload,
allow_symlink,
render_index,
render_spa,
})
}