@@ -1048,6 +1048,41 @@ impl HttpServer {
10481048 pub fn get_ws_channels ( & self ) -> HashMap < String , HashSet < u32 > > {
10491049 self . ws_channels . clone ( )
10501050 }
1051+
1052+ /// Register multiple paths with the HTTP server using the same configuration.
1053+ /// The security setting is determined by the `secure_subdomain` field in `HttpBindingConfig`.
1054+ /// All paths must be bound successfully, or none will be bound. If any path
1055+ /// fails to bind, all previously bound paths will be unbound before returning
1056+ /// the error.
1057+ pub fn bind_multiple_http_paths < T : Into < String > > (
1058+ & mut self ,
1059+ paths : Vec < T > ,
1060+ config : HttpBindingConfig ,
1061+ ) -> Result < ( ) , HttpServerError > {
1062+ let mut bound_paths = Vec :: new ( ) ;
1063+
1064+ for path in paths {
1065+ let path_str = path. into ( ) ;
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 ( ) ) ,
1069+ } ;
1070+
1071+ match result {
1072+ // If binding succeeds, add the path to the list of bound paths
1073+ Ok ( _) => bound_paths. push ( path_str) ,
1074+ // If binding fails, unbind all previously bound paths
1075+ Err ( e) => {
1076+ for bound_path in bound_paths {
1077+ let _ = self . unbind_http_path ( & bound_path) ;
1078+ }
1079+ return Err ( e) ;
1080+ }
1081+ }
1082+ }
1083+
1084+ Ok ( ( ) )
1085+ }
10511086}
10521087
10531088/// Send an HTTP response to an incoming HTTP request ([`HttpServerRequest::Http`]).
0 commit comments