class

Kemal::EventStream

Inherits Reference < Object

Helper for Server-Sent Events (SSE) responses.

Sets the required headers and formats events according to the SSE spec.

Constructors

Class methods

serve(context : HTTP::Server::Context, & : EventStream, HTTP::Server::Context -> )

Runs an SSE handler with headers configured and yields an EventStream.

Source

Instance methods

close
Source
comment(text : String) : self

Sends a keep-alive comment (ignored by clients, useful during idle periods).

Source
flush
Source
send(data : String, *, event : String | Nil = nil, id : String | Int | Nil = nil, retry : Time::Span | Nil = nil) : self

Sends an SSE event. Multi-line data is split into separate data: fields.

Source