aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorNorberto Lopes <nlopes.ml@gmail.com>2023-08-04 16:00:11 +0000
committerNorberto Lopes <nlopes.ml@gmail.com>2023-08-06 08:34:08 +0000
commit1fd606031d018854d2b8d08d30863105567fcccc (patch)
treead263938cd57951c519f3351b7ca9d9a480c7f4f /src/config.rs
parentAdd CHANGELOG entry for #1191 (diff)
downloadminiserve-1fd606031d018854d2b8d08d30863105567fcccc.tar.gz
miniserve-1fd606031d018854d2b8d08d30863105567fcccc.zip
Add pretty urls
This adds a new flag namely `--pretty-urls` that when enabled will serve the equivalent `.html` if it exists. Very much the same approach that [`netlify` uses](https://docs.netlify.com/site-deploys/post-processing/). It can be quite useful when having hrefs like `/about` serve `/about.html`.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 8976d35..2df9fdd 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -80,6 +80,13 @@ pub struct MiniserveConfig {
/// allow the SPA router to handle the request instead.
pub spa: bool,
+ /// Activate Pretty URLs mode
+ ///
+ /// This will cause the server to serve the equivalent `.html` file indicated by the path.
+ ///
+ /// `/about` will try to find `about.html` and serve it.
+ pub pretty_urls: bool,
+
/// Enable QR code display
pub show_qrcode: bool,
@@ -250,6 +257,7 @@ impl MiniserveConfig {
default_color_scheme_dark,
index: args.index,
spa: args.spa,
+ pretty_urls: args.pretty_urls,
overwrite_files: args.overwrite_files,
show_qrcode: args.qrcode,
mkdir_enabled: args.mkdir_enabled,