aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/config.rs b/src/config.rs
index 0959e81..8a8a876 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,6 +1,6 @@
-#[cfg(feature = "tls")]
-use std::{fs::File, io::BufReader};
use std::{
+ fs::File,
+ io::{BufRead, BufReader},
net::{IpAddr, Ipv4Addr, Ipv6Addr},
path::PathBuf,
};
@@ -14,7 +14,7 @@ use http::HeaderMap;
use rustls_pemfile as pemfile;
use crate::{
- args::{CliArgs, MediaType},
+ args::{parse_auth, CliArgs, MediaType},
auth::RequiredAuth,
file_utils::sanitize_path,
renderer::ThemeSlug,
@@ -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,
@@ -157,6 +164,17 @@ impl MiniserveConfig {
_ => "".to_owned(),
};
+ let mut auth = args.auth;
+
+ if let Some(path) = args.auth_file {
+ let file = File::open(path)?;
+ let lines = BufReader::new(file).lines();
+
+ for line in lines {
+ auth.push(parse_auth(line?.as_str())?);
+ }
+ }
+
// Generate some random routes for the favicon and css so that they are very unlikely to conflict with
// real files.
// If --random-route is enabled , in order to not leak the random generated route, we must not use it
@@ -254,7 +272,7 @@ impl MiniserveConfig {
path: args.path.unwrap_or_else(|| PathBuf::from(".")),
port,
interfaces,
- auth: args.auth,
+ auth,
path_explicitly_chosen,
no_symlinks: args.no_symlinks,
show_hidden: args.hidden,
@@ -265,6 +283,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,