Companion

The factories.

Functions

Link copied to clipboard
fun fail(failure: TransportFailure, delay: Duration = Duration.ZERO): Step

Fails with failure: execute returns Result.failure(failure), the same instance on every repeat.

fun fail(delay: Duration = Duration.ZERO, failure: () -> TransportFailure): Step

Fails with a fresh failure from failure on every call.

Link copied to clipboard
fun fixture(fixture: Fixture, delay: Duration = Duration.ZERO): Step

Responds with fixture (Fixture.toResponse) from the request's own URL.

Link copied to clipboard
fun respond(delay: Duration = Duration.ZERO, response: suspend (HttpRequest) -> HttpResponse): Step

Responds with whatever response builds for the request: a response with a redirectChain, another final URL, or anything else the built-in shapes cannot express. It runs once per call.

fun respond(status: Int, headers: HttpHeaders, body: ByteArray, delay: Duration = Duration.ZERO): Step

Responds with status, headers and the bytes of body, from the request's own URL.

fun respond(status: Int = 200, headers: HttpHeaders = HttpHeaders(), body: String = "", delay: Duration = Duration.ZERO): Step

Responds with status, headers and body as UTF-8, from the request's own URL.