Skip to content

Commit 83be28b

Browse files
Eliminate clippy redundant else error from src/webserver/http.rs
cargo clippy Checking sqlpage v0.38.0 error: redundant else block --> src\webserver\http.rs:493:6 | 493 | } else { | ______^ 494 | | if let Some(domain) = &config.https_domain { 495 | | let mut listen_on_https = listen_on; 496 | | listen_on_https.set_port(443); ... | 511 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else note: the lint level is defined here --> src\lib.rs:1:9 | 1 | #![deny(clippy::pedantic)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::redundant_else)]` implied by `#[deny(clippy::pedantic)]` help: remove the `else` block and move the contents out | 493 ~ } 494 + if let Some(domain) = &config.https_domain { 495 + let mut listen_on_https = listen_on; 496 + listen_on_https.set_port(443); 497 + log::debug!("Will start HTTPS server on {listen_on_https}"); 498 + let config = make_auto_rustls_config(domain, config); 499 + server = server 500 + .bind_rustls_0_23(listen_on_https, config) 501 + .map_err(|e| bind_error(e, listen_on_https))?; 502 + } else if listen_on.port() == 443 { 503 + bail!("Please specify a value for https_domain in the configuration file. This is required when using HTTPS (port 443)"); 504 + } 505 + if listen_on.port() != 443 { 506 + log::debug!("Will start HTTP server on {listen_on}"); 507 + server = server 508 + .bind(listen_on) 509 + .map_err(|e| bind_error(e, listen_on))?; 510 + } | error: could not compile `sqlpage` (lib) due to 1 previous error
1 parent 3654d42 commit 83be28b

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

src/webserver/http.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -490,24 +490,23 @@ pub async fn run_server(config: &AppConfig, state: AppState) -> anyhow::Result<(
490490
}
491491
#[cfg(not(target_family = "unix"))]
492492
anyhow::bail!("Unix sockets are not supported on your operating system. Use listen_on instead of unix_socket.");
493-
} else {
494-
if let Some(domain) = &config.https_domain {
495-
let mut listen_on_https = listen_on;
496-
listen_on_https.set_port(443);
497-
log::debug!("Will start HTTPS server on {listen_on_https}");
498-
let config = make_auto_rustls_config(domain, config);
499-
server = server
500-
.bind_rustls_0_23(listen_on_https, config)
501-
.map_err(|e| bind_error(e, listen_on_https))?;
502-
} else if listen_on.port() == 443 {
503-
bail!("Please specify a value for https_domain in the configuration file. This is required when using HTTPS (port 443)");
504-
}
505-
if listen_on.port() != 443 {
506-
log::debug!("Will start HTTP server on {listen_on}");
507-
server = server
508-
.bind(listen_on)
509-
.map_err(|e| bind_error(e, listen_on))?;
510-
}
493+
}
494+
if let Some(domain) = &config.https_domain {
495+
let mut listen_on_https = listen_on;
496+
listen_on_https.set_port(443);
497+
log::debug!("Will start HTTPS server on {listen_on_https}");
498+
let config = make_auto_rustls_config(domain, config);
499+
server = server
500+
.bind_rustls_0_23(listen_on_https, config)
501+
.map_err(|e| bind_error(e, listen_on_https))?;
502+
} else if listen_on.port() == 443 {
503+
bail!("Please specify a value for https_domain in the configuration file. This is required when using HTTPS (port 443)");
504+
}
505+
if listen_on.port() != 443 {
506+
log::debug!("Will start HTTP server on {listen_on}");
507+
server = server
508+
.bind(listen_on)
509+
.map_err(|e| bind_error(e, listen_on))?;
511510
}
512511

513512
log_welcome_message(config);

0 commit comments

Comments
 (0)