From a24f880d04af6114eeb59c560095a0f6de68afef Mon Sep 17 00:00:00 2001 From: Erik Hollensbe Date: Sat, 9 Aug 2025 12:51:41 -0700 Subject: [PATCH 1/2] add post handling to library Signed-off-by: Erik Hollensbe --- src/event_source.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/event_source.rs b/src/event_source.rs index a18ee1a..e08b668 100644 --- a/src/event_source.rs +++ b/src/event_source.rs @@ -88,6 +88,17 @@ impl EventSource { Self::new(reqwest::Client::new().get(url)).unwrap() } + /// Create a simple EventSource based on a GET request + pub fn post(url: T, content_type: &str, input: reqwest::Body) -> Self { + Self::new( + reqwest::Client::new() + .post(url) + .body(input) + .header(reqwest::header::CONTENT_TYPE, content_type), + ) + .unwrap() + } + /// Close the EventSource stream and stop trying to reconnect pub fn close(&mut self) { self.is_closed = true; From edcd36c1ae010e8766a52cc11e9ab4c357bb1a63 Mon Sep 17 00:00:00 2001 From: Erik Hollensbe Date: Wed, 13 Aug 2025 09:51:24 -0700 Subject: [PATCH 2/2] add PUT, fix documentation Signed-off-by: Erik Hollensbe --- src/event_source.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/event_source.rs b/src/event_source.rs index e08b668..0e24e72 100644 --- a/src/event_source.rs +++ b/src/event_source.rs @@ -88,7 +88,7 @@ impl EventSource { Self::new(reqwest::Client::new().get(url)).unwrap() } - /// Create a simple EventSource based on a GET request + /// Create a simple EventSource based on a POST request pub fn post(url: T, content_type: &str, input: reqwest::Body) -> Self { Self::new( reqwest::Client::new() @@ -99,6 +99,17 @@ impl EventSource { .unwrap() } + /// Create a simple EventSource based on a PUT request + pub fn put(url: T, content_type: &str, input: reqwest::Body) -> Self { + Self::new( + reqwest::Client::new() + .put(url) + .body(input) + .header(reqwest::header::CONTENT_TYPE, content_type), + ) + .unwrap() + } + /// Close the EventSource stream and stop trying to reconnect pub fn close(&mut self) { self.is_closed = true;