aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2021-08-28 18:41:32 +0000
committerGitHub <noreply@github.com>2021-08-28 18:41:32 +0000
commit1c344f2625c1a7a4bfdf20fd891dd86f84ff8b76 (patch)
tree4e08f16c25c3f7080c454bead5791880587077e7 /src/main.rs
parent(cargo-release) start next development iteration 0.15.1-alpha.0 (diff)
parentSwitch TLS conditional compilation to feature (diff)
downloadminiserve-1c344f2625c1a7a4bfdf20fd891dd86f84ff8b76.tar.gz
miniserve-1c344f2625c1a7a4bfdf20fd891dd86f84ff8b76.zip
Merge pull request #580 from svenstaro/conditional-tls
Conditionally enable TLS only on supported platforms
Diffstat (limited to '')
-rw-r--r--src/main.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 1432a1a..c60e153 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -227,6 +227,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
.default_service(web::get().to(error_404))
});
+ #[cfg(feature = "tls")]
let srv = if let Some(tls_config) = miniserve_config.tls_rustls_config {
srv.bind_rustls(socket_addresses.as_slice(), tls_config)
.map_err(|e| ContextualError::IoError("Failed to bind server".to_string(), e))?
@@ -239,6 +240,13 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
.run()
};
+ #[cfg(not(feature = "tls"))]
+ let srv = srv
+ .bind(socket_addresses.as_slice())
+ .map_err(|e| ContextualError::IoError("Failed to bind server".to_string(), e))?
+ .shutdown_timeout(0)
+ .run();
+
println!(
"Serving path {path} at {addresses}",
path = Color::Yellow.paint(path_string).bold(),