Skip to content

Commit 9abf96d

Browse files
authored
Merge pull request #112 from kinode-dao/hf/http-fixes
http fixes
2 parents 50400d4 + 51369db commit 9abf96d

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/http/server.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::{
33
get_blob, Address, LazyLoadBlob as KiBlob, Message, Request as KiRequest,
44
Response as KiResponse,
55
};
6-
use http::{HeaderMap, HeaderName, HeaderValue, StatusCode};
6+
pub use http::StatusCode;
7+
use http::{HeaderMap, HeaderName, HeaderValue};
78
use serde::{Deserialize, Serialize};
89
use std::collections::{HashMap, HashSet};
910
use thiserror::Error;
@@ -1041,11 +1042,11 @@ impl HttpServer {
10411042

10421043
/// Push a WebSocket message to all channels on a given path.
10431044
pub fn ws_push_all_channels(&self, path: &str, message_type: WsMessageType, blob: KiBlob) {
1044-
if let Some(channels) = self.ws_channels.get(path) {
1045-
channels.iter().for_each(|channel_id| {
1046-
send_ws_push(*channel_id, message_type, blob.clone());
1047-
});
1048-
}
1045+
ws_push_all_channels(&self.ws_channels, path, message_type, blob);
1046+
}
1047+
1048+
pub fn get_ws_channels(&self) -> HashMap<String, HashSet<u32>> {
1049+
self.ws_channels.clone()
10491050
}
10501051
}
10511052

@@ -1079,6 +1080,19 @@ pub fn send_ws_push(channel_id: u32, message_type: WsMessageType, blob: KiBlob)
10791080
.unwrap()
10801081
}
10811082

1083+
pub fn ws_push_all_channels(
1084+
ws_channels: &HashMap<String, HashSet<u32>>,
1085+
path: &str,
1086+
message_type: WsMessageType,
1087+
blob: KiBlob,
1088+
) {
1089+
if let Some(channels) = ws_channels.get(path) {
1090+
channels.iter().for_each(|channel_id| {
1091+
send_ws_push(*channel_id, message_type, blob.clone());
1092+
});
1093+
}
1094+
}
1095+
10821096
/// Guess the MIME type of a file from its extension.
10831097
pub fn get_mime_type(filename: &str) -> String {
10841098
let file_path = std::path::Path::new(filename);

0 commit comments

Comments
 (0)