responds With Sse Stream
fun <T : Any> respondsWithSseStream(dataType: Class<T>, configurer: Consumer<JavaStreamingResponseDefinitionBuilder<P, ServerSentEventMetadata<T>>>)(source)
Configures a typed SSE streaming response for this stub.
The dataType parameter represents the type of the data field in each ServerSentEventMetadata event. The consumer receives a JavaStreamingResponseDefinitionBuilder parameterised over ServerSentEventMetadata<T>, so chunks should be ServerSentEvent or TypedServerSentEvent instances.
Example (Java):
mokksy.get(spec -> spec.path("/sse"))
.respondsWithSseStream(String.class, builder -> builder
.chunk(new ServerSentEvent("Hello", null, null, null, null))
.chunk(new ServerSentEvent("World", null, null, null, null)));Content copied to clipboard
Parameters
data Type
The Java Class of the SSE event data type.
configurer
A Consumer that configures a JavaStreamingResponseDefinitionBuilder.
Type Parameters
T
The type of the data field in each SSE event.
fun respondsWithSseStream(configurer: Consumer<JavaStreamingResponseDefinitionBuilder<P, ServerSentEventMetadata<String>>>)(source)
Configures an SSE streaming response for this stub with ServerSentEventMetadata<String> chunks.
Shorthand for respondsWithSseStream(String.class, configurer).
Parameters
configurer
A Consumer that configures a JavaStreamingResponseDefinitionBuilder.