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(-)
@@ -6,9 +6,7 @@
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};
@@ -25,11 +25,23 @@ pub struct General {
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"])
)
)]
@@ -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()
}