ResponseDefinitionBuilder

open class ResponseDefinitionBuilder<P : Any, T : Any>(val request: CapturedRequest<P>, var contentType: <Error class: unknown class>? = null, var body: T? = null, httpStatus: <Error class: unknown class> = HttpStatusCode.OK, headers: MutableList<<Error class: unknown class><String, String>> = mutableListOf()) : AbstractResponseDefinitionBuilder<P, T>

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

Parameters

P

The type of the request body.

T

The type of the response body.

httpStatus

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

headers

A mutable list of additional custom headers for the response.

Inherits functionality from AbstractResponseDefinitionBuilder to allow additional header manipulations and provides a concrete implementation of the response building process.

Constructors

Link copied to clipboard
constructor(request: CapturedRequest<P>, contentType: <Error class: unknown class>? = null, body: T? = null, httpStatus: <Error class: unknown class> = HttpStatusCode.OK, headers: MutableList<<Error class: unknown class><String, String>> = mutableListOf())

Properties

Link copied to clipboard
var body: T?

The body of the response. Can be null.

Link copied to clipboard
var contentType: <Error class: unknown class>?

Optional MIME type of the response. Defaults to ContentType.Application.Json if not specified.

Link copied to clipboard
var delay: <Error class: unknown class>
Link copied to clipboard
val headers: MutableList<<Error class: unknown class><String, String>>

A mutable list of header key-value pairs to be included in the response.

Link copied to clipboard
var httpStatus: <Error class: unknown class>

The HTTP status code to be associated with the response.

Link copied to clipboard

Functions

Link copied to clipboard
open override fun build(): ResponseDefinition<P, T>

Abstract method to build a concrete response definition.

Link copied to clipboard
fun delayMillis(millis: Long)

Sets a delay for the response in milliseconds.

Link copied to clipboard
fun headers(block: <Error class: unknown class>.() -> Unit)

Configures additional headers for the response using the specified lambda block.

Link copied to clipboard
fun httpStatus(status: Int)