SseStreamResponseDefinition

open class SseStreamResponseDefinition<P>(val chunkFlow: Flow<ServerSentEvent>? = null, chunkContentType: ContentType? = null, delay: Duration = Duration.ZERO, formatter: HttpFormatter) : StreamResponseDefinition<P, ServerSentEvent> (source)

Represents a response definition for server-sent events (SSE) streaming.

This class extends StreamResponseDefinition and is used to configure and handle an SSE response. It provides functionality for sending a stream of SSE events to the client, utilizing a specified chunkFlow and configuring response metadata.

Author

Konstantin Pavlov

Parameters

P

The payload type for the SSE events.

chunkFlow

A Flow of ServerSentEvent representing the stream of SSE events. Defaults to null.

chunkContentType

The ContentType for the chunks in the SSE stream. Defaults to null.

delay

An optional delay between chunks, specified as a Duration. Defaults to Duration.ZERO.

formatter

An HttpFormatter responsible for formatting the HTTP response or payloads.

Constructors

Link copied to clipboard
constructor(chunkFlow: Flow<ServerSentEvent>? = null, chunkContentType: ContentType? = null, delay: Duration = Duration.ZERO, formatter: HttpFormatter)

Properties

Link copied to clipboard
open override val chunkFlow: Flow<ServerSentEvent>?
Link copied to clipboard

A list of chunks representing the response data to be sent.

Link copied to clipboard

The MIME type of the response content.

Link copied to clipboard
open val delay: Duration

A delay applied before sending the response. Defaults to Duration.ZERO.

Link copied to clipboard

Delay between the transmission of each chunk.

Link copied to clipboard

A lambda that configures the response headers. Defaults to null.

Link copied to clipboard

The HTTP status code of the response. Defaults to HttpStatusCode.OK.

Link copied to clipboard

The HTTP status code of the response as Int, defaulting to 200.

Link copied to clipboard

The optional response payload associated with this definition.

Functions

Link copied to clipboard

Modifies the response body of this response definition using the provided transformation logic.