AbstractResponseDefinition

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)(source)

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.

Author

Konstantin Pavlov

Parameters

T

The type of the response data.

Inheritors

Constructors

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

Properties

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

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
fun withResponseBody(block: T?.() -> T?)

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