Skip to content

Commit d5ebd84

Browse files
committed
amend the binding function
1 parent 11bff07 commit d5ebd84

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/http/server.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,36 +1050,29 @@ impl HttpServer {
10501050
}
10511051

10521052
/// Register multiple paths with the HTTP server using the same configuration.
1053-
/// Uses the security setting from HttpBindingConfig if secure is None,
1054-
/// forces secure binding if Some(true), or forces non-secure binding if Some(false).
1053+
/// The security setting is determined by the `secure_subdomain` field in `HttpBindingConfig`.
10551054
/// All paths must be bound successfully, or none will be bound. If any path
10561055
/// fails to bind, all previously bound paths will be unbound before returning
10571056
/// the error.
10581057
pub fn bind_multiple_http_paths<T: Into<String>>(
10591058
&mut self,
10601059
paths: Vec<T>,
10611060
config: HttpBindingConfig,
1062-
secure: Option<bool>,
10631061
) -> Result<(), HttpServerError> {
10641062
let mut bound_paths = Vec::new();
1065-
1063+
10661064
for path in paths {
10671065
let path_str = path.into();
1068-
let result = match secure {
1069-
Some(true) => self.secure_bind_http_path(path_str.clone()),
1070-
Some(false) => self.bind_http_path(path_str.clone(), config.clone()),
1071-
None => {
1072-
if config.secure_subdomain {
1073-
self.secure_bind_http_path(path_str.clone())
1074-
} else {
1075-
self.bind_http_path(path_str.clone(), config.clone())
1076-
}
1077-
}
1066+
let result = match config.secure_subdomain {
1067+
true => self.secure_bind_http_path(path_str.clone()),
1068+
false => self.bind_http_path(path_str.clone(), config.clone()),
10781069
};
1070+
10791071
match result {
1072+
// If binding succeeds, add the path to the list of bound paths
10801073
Ok(_) => bound_paths.push(path_str),
1074+
// If binding fails, unbind all previously bound paths
10811075
Err(e) => {
1082-
// If binding fails, unbind all previously bound paths
10831076
for bound_path in bound_paths {
10841077
let _ = self.unbind_http_path(&bound_path);
10851078
}

0 commit comments

Comments
 (0)