index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2021-05-19 9:32:26.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2021-05-19 9:37:15.0 +00:00:00
commit
da67063bcc3cea664608adcc860fc40f34500507 [patch]
tree
d94b11d210805746d2a3175b0309b579a1565eba
parent
8ecc5b45fad139cfaac05e9dbaf2a94b9a3b5996
download
da67063bcc3cea664608adcc860fc40f34500507.tar.gz

refactor: boolean literal parsing for --directory-listing argument



Diff

 src/config.rs |  9 +++++++--
 src/server.rs |  2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/config.rs b/src/config.rs
index 3481560..6bbda94 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -68,7 +68,12 @@ pub struct Config {
    /// Specify the file path to read the private key.
    pub http2_tls_key: String,

    #[structopt(long, short = "z", env = "SERVER_DIRECTORY_LISTING")]
    #[structopt(
        long,
        short = "z",
        parse(try_from_str),
        env = "SERVER_DIRECTORY_LISTING"
    )]
    /// Enable directory listing for all requests ending with the slash character (‘/’).
    pub directory_listing: Option<bool>,
    pub directory_listing: bool,
}
diff --git a/src/server.rs b/src/server.rs
index ae40d51..c04fe51 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -76,7 +76,7 @@ impl Server {
        // TODO: CORS support

        // Directory listing option
        let dir_listing = opts.directory_listing.unwrap_or_default();
        let dir_listing = opts.directory_listing;

        // Spawn a new Tokio asynchronous server task with its given options
        let threads = self.threads;