index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2023-06-12 21:03:26.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2023-06-13 22:35:08.0 +00:00:00
commit
558fd96cf01bb92844c54ee897cb12a96aec9bf1 [patch]
tree
ebfed3b081b4c7db4e15b3c7fc345da5e48fc459
parent
79a93f69edbc1baa9475f2978cacf4e44577f424
download
558fd96cf01bb92844c54ee897cb12a96aec9bf1.tar.gz

fix: unresolved/unused imports when disabling all cargo features

for example if sws is built using:

cargo build --release --verbose --no-default-features

Diff

 src/server.rs       |  9 ++++-----
 src/settings/cli.rs | 22 +++++++++++++++++-----
 src/settings/mod.rs |  5 +++++
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/server.rs b/src/server.rs
index cc71218..d0b800e 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -6,9 +6,7 @@
//! Server module intended to construct a multi-thread HTTP or HTTP/2 web server.
//!

use hyper::server::conn::AddrStream;
use hyper::server::Server as HyperServer;
use hyper::service::{make_service_fn, service_fn};
use listenfd::ListenFd;
use std::net::{IpAddr, SocketAddr, TcpListener};
use std::sync::Arc;
@@ -21,11 +19,12 @@ use crate::signals;
#[cfg(feature = "http2")]
use {
    crate::tls::{TlsAcceptor, TlsConfigBuilder},
    hyper::server::conn::AddrIncoming,
    crate::{error, error_page, https_redirect},
    hyper::server::conn::{AddrIncoming, AddrStream},
    hyper::service::{make_service_fn, service_fn},
};

use crate::https_redirect;
use crate::{cors, error, error_page, helpers, logger, Settings};
use crate::{cors, helpers, logger, Settings};
use crate::{service::RouterService, Context, Result};

/// Define a multi-thread HTTP or HTTP/2 web server.
diff --git a/src/settings/cli.rs b/src/settings/cli.rs
index 68dfe3f..bd46793 100644
--- a/src/settings/cli.rs
+++ b/src/settings/cli.rs
@@ -25,11 +25,23 @@ pub struct General {
    /// Host port
    pub port: u16,

    #[arg(
        long,
        short = 'f',
        env = "SERVER_LISTEN_FD",
        conflicts_with_all(&["host", "port", "https_redirect"])
    #[cfg_attr(
        feature = "http2",
        arg(
            long,
            short = 'f',
            env = "SERVER_LISTEN_FD",
            conflicts_with_all(&["host", "port", "https_redirect"])
        )
    )]
    #[cfg_attr(
        not(feature = "http2"),
        arg(
            long,
            short = 'f',
            env = "SERVER_LISTEN_FD",
            conflicts_with_all(&["host", "port"])
        )
    )]
    /// Instead of binding to a TCP port, accept incoming connections to an already-bound TCP
    /// socket listener on the specified file descriptor number (usually zero). Requires that the
diff --git a/src/settings/mod.rs b/src/settings/mod.rs
index 96bff28..70a928a 100644
--- a/src/settings/mod.rs
+++ b/src/settings/mod.rs
@@ -204,6 +204,7 @@ impl Settings {
                    if let Some(v) = general.https_redirect_from_hosts {
                        https_redirect_from_hosts = v
                    }
                    #[cfg(feature = "http2")]
                    match general.security_headers {
                        Some(v) => security_headers = v,
                        _ => {
@@ -212,6 +213,10 @@ impl Settings {
                            }
                        }
                    }
                    #[cfg(not(feature = "http2"))]
                    if let Some(v) = general.security_headers {
                        security_headers = v
                    }
                    if let Some(ref v) = general.cors_allow_origins {
                        cors_allow_origins = v.to_owned()
                    }