mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 06:34:26 +01:00
fix: post endpoint url on sse endpoint event (#900)
This commit is contained in:
@@ -43,7 +43,7 @@ async fn main() -> Result<()> {
|
||||
println!("Connected to server: {server_info:?}\n");
|
||||
|
||||
// Sleep for 100ms to allow the server to start - surprisingly this is required!
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
|
||||
// List tools
|
||||
let tools = client.list_tools(None).await?;
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, RwLock};
|
||||
use tokio::time::{timeout, Duration};
|
||||
use tracing::warn;
|
||||
use url::Url;
|
||||
|
||||
use super::{send_message, Transport, TransportHandle};
|
||||
|
||||
@@ -90,12 +91,13 @@ impl SseActor {
|
||||
match event {
|
||||
SSE::Event(e) if e.event_type == "endpoint" => {
|
||||
// SSE server uses the "endpoint" event to tell us the POST URL
|
||||
let base_url = sse_url.trim_end_matches('/').trim_end_matches("sse");
|
||||
let endpoint_path = e.data.trim_start_matches('/');
|
||||
let post_url = format!("{}{}", base_url, endpoint_path);
|
||||
let base_url = Url::parse(&sse_url).expect("Invalid base URL");
|
||||
let post_url = base_url
|
||||
.join(&e.data)
|
||||
.expect("Failed to resolve endpoint URL");
|
||||
|
||||
println!("Discovered SSE POST endpoint: {post_url}");
|
||||
*post_endpoint.write().await = Some(post_url);
|
||||
println!("Discovered SSE POST endpoint: {}", post_url);
|
||||
*post_endpoint.write().await = Some(post_url.to_string());
|
||||
break;
|
||||
}
|
||||
_ => continue,
|
||||
|
||||
Reference in New Issue
Block a user