diff options
author | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2022-02-06 10:12:19 +0000 |
---|---|---|
committer | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2022-02-06 10:12:19 +0000 |
commit | 8e0930cc9f25e44a69f61763ac5ff38ba58bb3dd (patch) | |
tree | e9500f4d2180984fe7981205c44ac89048f1019c /src/config.rs | |
parent | Merge pull request #725 from aliemjay/update_actix_web (diff) | |
parent | Apply alimjays suggestion (diff) | |
download | miniserve-8e0930cc9f25e44a69f61763ac5ff38ba58bb3dd.tar.gz miniserve-8e0930cc9f25e44a69f61763ac5ff38ba58bb3dd.zip |
Merge 'jikstra/feat_route_prefix' #682
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/config.rs b/src/config.rs index ccff7e3..ae260af 100644 --- a/src/config.rs +++ b/src/config.rs @@ -47,8 +47,8 @@ pub struct MiniserveConfig { /// Show hidden files pub show_hidden: bool, - /// Enable random route generation - pub random_route: Option<String>, + /// Route prefix + pub route_prefix: String, /// Randomly generated favicon route pub favicon_route: String, @@ -131,10 +131,10 @@ impl MiniserveConfig { ] }; - let random_route = if args.random_route { - Some(nanoid::nanoid!(6, &ROUTE_ALPHABET)) - } else { - None + let route_prefix = match (args.route_prefix, args.random_route) { + (Some(prefix), _) => format!("/{}", prefix.trim_matches('/')), + (_, true) => format!("/{}", nanoid::nanoid!(6, &ROUTE_ALPHABET)), + _ => "".to_owned(), }; // Generate some random routes for the favicon and css so that they are very unlikely to conflict with @@ -197,7 +197,7 @@ impl MiniserveConfig { path_explicitly_chosen, no_symlinks: args.no_symlinks, show_hidden: args.hidden, - random_route, + route_prefix, favicon_route, css_route, default_color_scheme, |