Class RequestTemplate
- Namespace
- Kuestenlogik.Bowire.Mock.Replay
- Assembly
- Kuestenlogik.Bowire.Mock.dll
Snapshot of the inbound HTTP request that response-body substitution
can project values out of at replay time. Lets recorded response
payloads reference the live request via ${request.*} tokens so
a single recording can power many test cases — think echo endpoints
or mocks that need to mirror a correlation id back to the caller.
public sealed class RequestTemplate
- Inheritance
-
RequestTemplate
- Inherited Members
Remarks
Supported token shape:
${request.method}— HTTP verb.${request.path}— full request path.${request.path.N}— 0-based path segment (/a/b/c→0=a, 1=b, 2=c).${request.path.NAME}— captured value of the{NAME}placeholder in the matched step'shttpPathtemplate, when the matcher compiled one.${request.query.NAME}— query value (repeat params return the first occurrence; case-insensitive lookup).${request.header.NAME}— request header value (case-insensitive).${request.body}— raw request body as a string (read once and cached).${request.body.a.b.c}— JSON-path navigation into the parsed request body. Dots step into object properties; integer segments step into JSON arrays (${request.body.items.0.id}).
Unknown tokens fall through to the substitutor's "leave literal"
behaviour so a ${request.whatever} in a recorded body stays
as-is rather than getting silently swallowed.
Constructors
RequestTemplate(HttpContext, string?, IReadOnlyDictionary<string, string>?)
Build a template from the live ctx. Pass the
already-read request body as body — the caller
is in a better position to buffer it once than the template is
(the substitutor can't re-read the stream mid-pipeline).
Path-template bindings come from the matcher's regex capture
when the matched step's httpPath contained
{name} placeholders; pass null otherwise.
public RequestTemplate(HttpContext ctx, string? body, IReadOnlyDictionary<string, string>? templateBindings)
Parameters
ctxHttpContextbodystringtemplateBindingsIReadOnlyDictionary<string, string>
Methods
Resolve(string)
Resolve a request.* sub-token. Returns null when
the token doesn't address anything the template can reach; the
substitutor treats that as "leave literal" so the final output
still contains the original placeholder text.
public string? Resolve(string subToken)
Parameters
subTokenstring