respondsWith

fun <P : Any, T : Any> BuildingStep<P>.respondsWith(responseType: Class<T>, configurer: Consumer<ResponseDefinitionBuilder<P, T>>)(source)

Java-friendly overload for BuildingStep.respondsWith.

Accepts a Class and a Consumer in place of a Kotlin suspend lambda.

Prefer MokksyServerJava, which returns JavaBuildingStep and allows fluent chaining:

mokksy.get(spec -> spec.path("/ping"))
.respondsWith(builder -> builder.setBody("Pong"));

Use this extension only when working directly with a BuildingStep obtained from the Kotlin MokksyServer API.

Parameters

T

The type of the response body.

responseType

The Java Class of the response type.

configurer

A Consumer applied to a ResponseDefinitionBuilder to configure the response.