Class ExactMatcher

Namespace
Kuestenlogik.Bowire.Mock.Matchers
Assembly
Kuestenlogik.Bowire.Mock.dll

Default matcher for the Phase-1 / Phase-2 mock. Handles two protocol families:

  • REST — matches recorded steps by (httpVerb, httpPath). The path is either a literal (/weather, exact string match) or an OpenAPI-style template (/users/{id}, each {name} segment binds to one path segment). Verb case-insensitive, literal-path case-sensitive per the HTTP spec.
  • gRPC — matches requests carrying an application/grpc-family content type by the /{service}/{method} URL path.

Non-unary steps are always skipped. When several recorded steps share the same verb + path template (e.g. three captures of GET /pet/{petId} with petId = 3, 5, 10), the matcher scores each candidate by how well its recorded request body matches the incoming path-bindings and picks the best hit — so a mock call against /pet/5 returns the response for petId = 5 instead of always handing back the first capture. Ties (and the historical single-template path) keep the original "first match wins" order. Phase 2 later adds a topic matcher for MQTT / Socket.IO wildcards as a separate IMockMatcher implementation.

public sealed class ExactMatcher : IMockMatcher
Inheritance
ExactMatcher
Implements
Inherited Members

Constructors

ExactMatcher()

public ExactMatcher()

Methods

ExtractTemplateBindings(string, string)

Extract named captures from a matched template. Returns null when template has no placeholders (nothing to bind) or doesn't match the path (caller got here via a different matcher). Uses the same cached regex as Kuestenlogik.Bowire.Mock.Matchers.ExactMatcher.MatchesRestVerbAndPath(Kuestenlogik.Bowire.Mocking.BowireRecordingStep,Kuestenlogik.Bowire.Mock.Matchers.MockRequest) so hot paths don't pay for a second compile.

public static IReadOnlyDictionary<string, string>? ExtractTemplateBindings(string template, string path)

Parameters

template string
path string

Returns

IReadOnlyDictionary<string, string>

TryMatch(MockRequest, BowireRecording, out BowireRecordingStep)

Try to pick a recorded step that answers this request.

public bool TryMatch(MockRequest request, BowireRecording recording, out BowireRecordingStep matchedStep)

Parameters

request MockRequest

Incoming wire request.

recording BowireRecording

The active recording to match against.

matchedStep BowireRecordingStep

The chosen step, if any.

Returns

bool

true if a step matched; false otherwise.