Class InterceptorMockRule
- Namespace
- Kuestenlogik.Bowire.Interceptor
- Assembly
- Kuestenlogik.Bowire.Interceptor.dll
One mock-injection rule (#308, Phase D). When the interceptor sees a request whose path + method match this rule's PathPattern
- Method, it short-circuits the pipeline and serves the rule's response directly — the host's endpoint never runs.
public sealed class InterceptorMockRule
- Inheritance
-
InterceptorMockRule
- Inherited Members
Remarks
Mirrors the recorded-mock surface (#36): the workbench's Mocks rail already knows how to express "this method + this body returns this status + this body". A mock rule is the same shape addressed by a route pattern rather than a discovered service/method pair — it can be authored from scratch in the Intercepted rail or seeded from an existing recording step.
The pattern grammar is deliberately small: literal path-prefix match
against the request path. A trailing /* is treated as a
wildcard tail. Method may be the literal verb or * to match
any method. This is enough for Phase D — full regex matching is left
to a script-sandbox hook (#126) where the operator has the full
language available.
Constructors
InterceptorMockRule()
public InterceptorMockRule()
Properties
DelayMs
Optional artificial latency (milliseconds) the middleware sleeps before writing the mocked response — useful for reproducing a slow upstream when testing client retry / timeout behaviour.
public int DelayMs { get; init; }
Property Value
Enabled
When false, the rule is kept in the store but not consulted by the matcher. The workbench surface uses this to pause a rule without losing the definition.
public bool Enabled { get; init; }
Property Value
Id
Stable id (URL-safe, monotonic) the workbench uses to address the rule for edit / delete. Assigned by InterceptorMockStore on insert.
public string Id { get; init; }
Property Value
Method
HTTP method to match (e.g. GET) or * for any. Match
is case-insensitive.
public string Method { get; init; }
Property Value
Name
Human-readable label that appears next to the rule in the rail. Defaults to "Method PathPattern" when the caller leaves it blank.
public string Name { get; init; }
Property Value
PathPattern
Path-prefix or wildcard pattern matched against the request path
(e.g. /api/users, /api/users/, ). The match
is case-insensitive — request paths typically arrive normalised
from ASP.NET routing.
public string PathPattern { get; init; }
Property Value
ResponseBody
Response body as UTF-8 text. Null serves an empty body.
public string? ResponseBody { get; init; }
Property Value
ResponseBodyBase64
When set, the response body is base64-decoded before writing — the path for binary mocks (e.g. a recorded image response). When both ResponseBody and ResponseBodyBase64 are set, the base64 wins.
public string? ResponseBodyBase64 { get; init; }
Property Value
ResponseHeaders
Response headers the mock emits. Content-Type defaults to
application/json when none is supplied — matches the
90%-case for REST mocks; the operator can override to plain text,
XML, &c.
public IReadOnlyList<KeyValuePair<string, string>> ResponseHeaders { get; init; }
Property Value
ResponseStatus
HTTP status code the mock returns to the client. Defaults to 200.
public int ResponseStatus { get; init; }
Property Value
Methods
Matches(string, string)
Does this rule match the supplied method + path? Case-insensitive
across both. PathPattern supports as the
"match any path" sentinel and a trailing / as the
"any tail" wildcard.
public bool Matches(string method, string path)