We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poem::web::sse::Event gives a mechanism (event_type()) for adding an event type to an sse event.
event_type()
poem_openapi::payload::EventStream does not, at least as far as I can tell. Is this possible?
The text was updated successfully, but these errors were encountered:
Add EventStream::to_event method to set a function used to convert …
EventStream::to_event
91614e4
…the message to SSE event. #378
Here is the example to show how to convert the message to SSE event:
poem/poem-openapi/src/payload/event_stream.rs
Line 70 in 91614e4
Sorry, something went wrong.
Awesome! 2.0.11 isn't on cargo yet, so I switched to git to try it out.
I was working from your poem_openapi sse example, so I ended up with something like this:
#[oai(path = "/foo", method = "get")] async fn foo(&self) -> EventStream<BoxStream<'static, serde_json::Value>> { EventStream::new( async_stream::stream! { for i in 0.. { tokio::time::sleep(Duration::from_secs(1)).await; yield serde_json::json!({"a": 3, "b": i}); } } .boxed(), ) .to_event(|ev| Event::message(ev.to_string()).event_type("foo")) }
Feel free to put this example into your repo.
No branches or pull requests
poem::web::sse::Event gives a mechanism (
event_type()
) for adding an event type to an sse event.poem_openapi::payload::EventStream does not, at least as far as I can tell. Is this possible?
The text was updated successfully, but these errors were encountered: