Skip to content

Commit cc1f566

Browse files
authored
Merge pull request #39 from kinode-dao/hf/http-ws-remove-unused-node-field
http: remove unused `node` field from ws methods
2 parents 3bf55ed + d939267 commit cc1f566

File tree

1 file changed

+10
-37
lines changed

1 file changed

+10
-37
lines changed

src/http.rs

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ pub fn serve_index_html(
496496
directory: &str,
497497
authenticated: bool,
498498
local_only: bool,
499-
) -> anyhow::Result<(), anyhow::Error> {
499+
) -> anyhow::Result<()> {
500500
let _ = KiRequest::new()
501501
.target("our@vfs:sys:nectar".parse::<Address>()?)
502502
.body(serde_json::to_vec(&VfsRequest {
@@ -529,7 +529,7 @@ pub fn serve_ui(
529529
directory: &str,
530530
authenticated: bool,
531531
local_only: bool,
532-
) -> anyhow::Result<(), anyhow::Error> {
532+
) -> anyhow::Result<()> {
533533
serve_index_html(our, directory, authenticated, local_only)?;
534534

535535
let initial_path = format!("{}/pkg/{}", our.package_id(), directory);
@@ -610,11 +610,7 @@ pub fn serve_ui(
610610
Ok(())
611611
}
612612

613-
pub fn handle_ui_asset_request(
614-
our: &Address,
615-
directory: &str,
616-
path: &str,
617-
) -> anyhow::Result<(), anyhow::Error> {
613+
pub fn handle_ui_asset_request(our: &Address, directory: &str, path: &str) -> anyhow::Result<()> {
618614
let parts: Vec<&str> = path.split(&our.process.to_string()).collect();
619615
let after_process = parts.get(1).unwrap_or(&"");
620616

@@ -649,16 +645,12 @@ pub fn handle_ui_asset_request(
649645
}
650646

651647
pub fn send_ws_push(
652-
node: String,
653648
channel_id: u32,
654649
message_type: WsMessageType,
655650
blob: KiBlob,
656651
) -> anyhow::Result<()> {
657652
KiRequest::new()
658-
.target(Address::new(
659-
node,
660-
"http_server:distro:sys".parse::<ProcessId>().unwrap(),
661-
))
653+
.target("our@http_server:distro:sys".parse::<Address>()?)
662654
.body(
663655
serde_json::json!(HttpServerRequest::WebSocketPush {
664656
channel_id,
@@ -675,16 +667,12 @@ pub fn send_ws_push(
675667
}
676668

677669
pub fn open_ws_connection(
678-
node: String,
679670
url: String,
680671
headers: Option<HashMap<String, String>>,
681672
channel_id: u32,
682673
) -> anyhow::Result<()> {
683674
KiRequest::new()
684-
.target(Address::new(
685-
node,
686-
ProcessId::from_str("http_client:distro:sys").unwrap(),
687-
))
675+
.target("our@http_client:distro:sys".parse::<Address>()?)
688676
.body(
689677
serde_json::json!(HttpClientAction::WebSocketOpen {
690678
url,
@@ -701,16 +689,12 @@ pub fn open_ws_connection(
701689
}
702690

703691
pub fn open_ws_connection_and_await(
704-
node: String,
705692
url: String,
706693
headers: Option<HashMap<String, String>>,
707694
channel_id: u32,
708695
) -> std::result::Result<std::result::Result<Message, SendError>, anyhow::Error> {
709696
KiRequest::new()
710-
.target(Address::new(
711-
node,
712-
ProcessId::from_str("http_client:distro:sys").unwrap(),
713-
))
697+
.target("our@http_client:distro:sys".parse::<Address>()?)
714698
.body(
715699
serde_json::json!(HttpClientAction::WebSocketOpen {
716700
url,
@@ -725,16 +709,12 @@ pub fn open_ws_connection_and_await(
725709
}
726710

727711
pub fn send_ws_client_push(
728-
node: String,
729712
channel_id: u32,
730713
message_type: WsMessageType,
731714
blob: KiBlob,
732715
) -> std::result::Result<(), anyhow::Error> {
733716
KiRequest::new()
734-
.target(Address::new(
735-
node,
736-
ProcessId::from_str("http_client:distro:sys").unwrap(),
737-
))
717+
.target("our@http_client:distro:sys".parse::<Address>()?)
738718
.body(
739719
serde_json::json!(HttpClientAction::WebSocketPush {
740720
channel_id,
@@ -748,12 +728,9 @@ pub fn send_ws_client_push(
748728
.send()
749729
}
750730

751-
pub fn close_ws_connection(node: String, channel_id: u32) -> anyhow::Result<()> {
731+
pub fn close_ws_connection(channel_id: u32) -> anyhow::Result<()> {
752732
KiRequest::new()
753-
.target(Address::new(
754-
node,
755-
ProcessId::from_str("http_client:distro:sys").unwrap(),
756-
))
733+
.target("our@http_client:distro:sys".parse::<Address>()?)
757734
.body(
758735
serde_json::json!(HttpClientAction::WebSocketClose { channel_id })
759736
.to_string()
@@ -766,14 +743,10 @@ pub fn close_ws_connection(node: String, channel_id: u32) -> anyhow::Result<()>
766743
}
767744

768745
pub fn close_ws_connection_and_await(
769-
node: String,
770746
channel_id: u32,
771747
) -> std::result::Result<std::result::Result<Message, SendError>, anyhow::Error> {
772748
KiRequest::new()
773-
.target(Address::new(
774-
node,
775-
ProcessId::from_str("http_client:distro:sys").unwrap(),
776-
))
749+
.target("our@http_client:distro:sys".parse::<Address>()?)
777750
.body(
778751
serde_json::json!(HttpClientAction::WebSocketClose { channel_id })
779752
.to_string()

0 commit comments

Comments
 (0)