refactor: https redirect feature improvements
Diff
src/lib.rs | 1 +
src/server.rs | 33 ++++++++++++++++-----------------
src/settings/cli.rs | 8 ++++----
3 files changed, 21 insertions(+), 21 deletions(-)
@@ -116,6 +116,7 @@ pub mod exts;
pub mod fallback_page;
pub mod handler;
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub mod https_redirect;
pub mod logger;
pub mod redirects;
@@ -235,22 +235,6 @@ impl Server {
let grace_period = general.grace_period;
tracing::info!("grace period before graceful shutdown: {}s", grace_period);
let https_redirect = general.https_redirect;
tracing::info!("http to https redirect: enabled={}", https_redirect);
tracing::info!(
"http to https redirect host: {}",
general.https_redirect_host
);
tracing::info!(
"http to https redirect from port: {}",
general.https_redirect_from_port
);
tracing::info!(
"http to https redirect from hosts: {}",
general.https_redirect_from_hosts
);
let router_service = RouterService::new(RequestHandler {
opts: Arc::from(RequestHandlerOpts {
@@ -292,8 +276,23 @@ impl Server {
#[cfg(feature = "http2")]
if general.http2 {
let https_redirect = general.https_redirect;
tracing::info!("http to https redirect: enabled={}", https_redirect);
tracing::info!(
"http to https redirect host: {}",
general.https_redirect_host
);
tracing::info!(
"http to https redirect from port: {}",
general.https_redirect_from_port
);
tracing::info!(
"http to https redirect from hosts: {}",
general.https_redirect_from_hosts
);
tcp_listener
.set_nonblocking(true)
.with_context(|| "failed to set TCP non-blocking mode")?;
@@ -12,7 +12,7 @@ use crate::directory_listing::DirListFmt;
#[derive(Debug, StructOpt)]
#[structopt(about, author)]
#[structopt(about, author, version)]
pub struct General {
#[structopt(long, short = 'a', default_value = "::", env = "SERVER_HOST")]
@@ -176,7 +176,7 @@ pub struct General {
long,
requires_if("true", "https-redirect"),
default_value = "localhost",
env = "HTTPS_REDIRECT_HOST"
env = "SERVER_HTTPS_REDIRECT_HOST"
)]
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
@@ -187,7 +187,7 @@ pub struct General {
long,
requires_if("true", "https-redirect"),
default_value = "80",
env = "HTTPS_REDIRECT_FROM_PORT"
env = "SERVER_HTTPS_REDIRECT_FROM_PORT"
)]
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
@@ -198,7 +198,7 @@ pub struct General {
long,
requires_if("true", "https-redirect"),
default_value = "localhost",
env = "HTTPS_REDIRECT_FROM_HOSTS"
env = "SERVER_HTTPS_REDIRECT_FROM_HOSTS"
)]
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]