Class WasmResponseShaper
shape_response export to the response a matched expectation
would return, enabling WASM-computed dynamic responses (ABI v3).
Fail-safe. Shaping is best-effort and never fails a request: any trap, oversized or
out-of-bounds return, or invalid JSON from the module leaves the materialised response untouched and
logs a single WARN per module (subsequent failures of the same module are silent, so a broken
module cannot flood the log). A module that does not export shape_response, or that returns
0 (opt out), is a no-op with no log.
Apply semantics. The module returns a possibly-partial response
{statusCode?, headers?, body?}: a present statusCode replaces the status; each entry
in a present headers object is merged in (overwriting a same-named header, adding new ones,
leaving unmentioned headers intact); a present, non-null body replaces the body. Absent fields
leave the corresponding response part unchanged.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClear the once-per-module warning dedup.voidshape(HttpResponse response, HttpRequest request, String moduleName, byte[] wasmBytes) Shaperesponsein place using the module'sshape_responseexport, if any.
-
Constructor Details
-
WasmResponseShaper
-
-
Method Details
-
shape
Shaperesponsein place using the module'sshape_responseexport, if any. A no-op (leavingresponseunchanged) when the module does not shape, opts out, or fails.- Parameters:
response- the materialised response to (possibly) rewrite — mutated in placerequest- the matched request (exposed to the module under the envelope'srequest)moduleName- the WASM module name (used for the once-per-module warning key)wasmBytes- the module bytes
-
resetWarnings
public static void resetWarnings()Clear the once-per-module warning dedup. Intended for tests that assert warn-once behaviour across separate cases; not used on the request path.
-