Class StreamTemplateRenderer
data, a WebSocket
text frame, or a gRPC server-stream message) against the triggering request, reusing exactly the same
template engines and request/template context (request.*, jsonPath, the built-in
helpers, faker and scenario) that HttpResponseTemplateActionHandler uses.
Opt-in, static-preserving: render(HttpTemplate.TemplateType, String, HttpRequest)
returns the payload unchanged when templateType is null (the default) — non-templated
streaming responses are byte-for-byte unchanged. Templating is applied only when a templateType
is explicitly set on the streaming action, and the payload is rendered once per event/message.
Engines: Velocity and Mustache render the payload text directly. JavaScript executes
the template's handle(request) function and coerces its return value to text
(TemplateEngine.renderTemplateText(String, HttpRequest)); if the GraalJS engine is not on the
classpath, a JAVASCRIPT templateType fails loudly with the same clear error the response-template
path uses rather than silently degrading. Engines are created lazily and cached per renderer instance,
mirroring HttpResponseTemplateActionHandler's lazy engine caching.
-
Constructor Summary
ConstructorsConstructorDescriptionStreamTemplateRenderer(MockServerLogger mockServerLogger, Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionrender(HttpTemplate.TemplateType templateType, String payload, HttpRequest request) Renderspayloadas a response template of the giventemplateTypeagainstrequest.
-
Constructor Details
-
StreamTemplateRenderer
-
-
Method Details
-
render
Renderspayloadas a response template of the giventemplateTypeagainstrequest. WhentemplateTypeorpayloadisnull, the payload is returned unchanged (static — no engine is created).
-