pub fn endpoint<F, Fut>(handle: F) -> SseEndpoint<F>Available on crate feature
sse only.Expand description
Creates an endpoint that can handle SSE connections. This directly upgrades the HTTP request to SSE unconditionally, before calling the handler function with the current request and the SSE sender.
ยงExamples
use under::sse::Sender;
async fn handle(req: Request, mut sender: Sender) -> Result<(), anyhow::Error> {
sender.send(None, "hello, world!", None).await?;
Ok(())
}
let mut http = under::http();
http.at("/sse").get(under::sse::endpoint(handle));