class
Kemal::EventStream
- Kemal::EventStream
- Reference
- Object
Overview
Helper for Server-Sent Events (SSE) responses.
Sets the required headers and formats events according to the SSE spec.
Defined in:
kemal/event_stream.crConstructors
Class Method Summary
-
.serve(context : HTTP::Server::Context, & : EventStream, HTTP::Server::Context -> )
Runs an SSE handler with headers configured and yields an
EventStream.
Instance Method Summary
- #close : Nil
-
#comment(text : String) : self
Sends a keep-alive comment (ignored by clients, useful during idle periods).
- #flush : Nil
-
#send(data : String, *, event : String | Nil = nil, id : String | Int | Nil = nil, retry : Time::Span | Nil = nil) : self
Sends an SSE event.
Constructor Detail
Class Method Detail
Runs an SSE handler with headers configured and yields an EventStream.
Instance Method Detail
def comment(text : String) : self
#
Sends a keep-alive comment (ignored by clients, useful during idle periods).
def 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.