ResponseDefinition

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

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.

Author

Konstantin Pavlov

Parameters

P

The type of the request body.

T

The type of the response body.

Constructors

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

Properties

Link copied to clipboard
val body: T?

The body of the response, which can be null.

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.