StreamResponseDefinition

open class StreamResponseDefinition<T>(val chunkFlow: Flow<T>, val delayBetweenChunks: Duration = Duration.ZERO, contentType: ContentType = ContentType.Text.EventStream.withCharset(Charsets.UTF_8), chunkContentType: ContentType? = null, httpStatus: HttpStatusCode = HttpStatusCode.OK, headers: ResponseHeaders.() -> Unit? = null, delay: Duration, formatter: HttpFormatter) : AbstractResponseDefinition<T> (source)

Represents a definition for streaming responses, supporting flow-based content streaming. This class extends AbstractResponseDefinition to provide functionality specific to streamed responses. It handles flow-based content delivery, manages chunk-wise delays, and supports various output formats.

Author

Konstantin Pavlov

Type Parameters

T

The type of the response data being streamed.

See also

Inheritors

Constructors

Link copied to clipboard
constructor(chunkFlow: Flow<T>, delayBetweenChunks: Duration = Duration.ZERO, contentType: ContentType = ContentType.Text.EventStream.withCharset(Charsets.UTF_8), chunkContentType: ContentType? = null, httpStatus: HttpStatusCode = HttpStatusCode.OK, headers: ResponseHeaders.() -> Unit? = null, delay: Duration, formatter: HttpFormatter)

Properties

Link copied to clipboard
open val chunkFlow: Flow<T>

A Flow of chunks to be streamed as part of the response.

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.

Functions

Link copied to clipboard

Returns the HTTP status code as an integer.