Package-level declarations

Response builders for plain (respondsWith), chunked stream (respondsWithStream), and SSE stream (respondsWithSseStream) responses.

Types

Link copied to clipboard
abstract class AbstractResponseDefinition<T>(val contentType: ContentType, val httpStatusCode: Int = 200, val httpStatus: HttpStatusCode = HttpStatusCode.fromValue(httpStatusCode), val headers: ResponseHeaders.() -> Unit? = null, val delay: Duration = Duration.ZERO, var responseBody: T? = null)

Represents the base definition of an HTTP response in a mapping between a request and its corresponding response. Provides the required attributes and behavior for configuring HTTP responses, including status code, headers, and content type. This class serves as the foundation for more specialized response definitions.

Link copied to clipboard
abstract class AbstractResponseDefinitionBuilder<P, T>(var delay: Duration = Duration.ZERO)

Represents a base abstraction for defining the attributes of an HTTP response in the context of request-to-response mappings. This class allows customization of the HTTP status code and headers and provides a mechanism for building concrete response definitions.

Link copied to clipboard
open class ResponseDefinition<P, T>(contentType: ContentType = ContentType.Application.Json, val body: T? = null, httpStatusCode: Int = 200, httpStatus: HttpStatusCode = HttpStatusCode.fromValue(httpStatusCode), headers: ResponseHeaders.() -> Unit? = null, delay: Duration, formatter: HttpFormatter) : AbstractResponseDefinition<T>

Represents a concrete implementation of an HTTP response definition with a specific response body. This class builds on the AbstractResponseDefinition to provide additional configuration and behavior.

Link copied to clipboard
open class ResponseDefinitionBuilder<P : Any, T : Any>(val request: CapturedRequest<P>, var contentType: ContentType? = null, var body: T? = null, httpStatusCode: Int = 200, httpStatus: HttpStatusCode = HttpStatusCode.fromValue(httpStatusCode), formatter: HttpFormatter) : AbstractResponseDefinitionBuilder<P, T>

Builder for constructing a definition of an HTTP response with configurable attributes.

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

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

Link copied to clipboard
open class StreamingResponseDefinitionBuilder<P : Any, T>(val request: CapturedRequest<P>, var flow: Flow<T>? = null, var chunks: MutableList<T> = mutableListOf(), var delayBetweenChunks: Duration = Duration.ZERO, httpStatus: HttpStatusCode = HttpStatusCode.OK, val chunkContentType: ContentType? = null, formatter: HttpFormatter) : AbstractResponseDefinitionBuilder<P, T>

A builder for constructing streaming response definitions.

Link copied to clipboard
open class StreamResponseDefinition<P, T>(val chunkFlow: Flow<T>? = null, val chunks: List<T>? = null, val delayBetweenChunks: Duration = Duration.ZERO, contentType: ContentType = ContentType.Text.EventStream.withCharset(Charsets.UTF_8), chunkContentType: ContentType? = null, httpStatusCode: Int = 200, httpStatus: HttpStatusCode = HttpStatusCode.fromValue(httpStatusCode), headers: ResponseHeaders.() -> Unit? = null, delay: Duration, formatter: HttpFormatter) : AbstractResponseDefinition<T>

Represents a definition for streaming responses, supporting chunked data and flow-based content streaming. This class extends the base AbstractResponseDefinition to provide additional functionality specific to chunked or streamed responses. It can handle flow-based content delivery, manage chunk-wise delays, and supports various output formats such as OutputStream, Writer, or ServerSSESession.