whenMatch method
void
whenMatch(
- CharlatanRequestMatcher requestMatcher,
- CharlatanResponseBuilder responseBuilder, {
- int statusCode = 200,
- String? description,
Adds a fake response definition for a request that matches the provided
requestMatcher
. If the response is not a CharlatanHttpResponse then
the statusCode
will be used.
description
is used to describe the response for debugging; it defaults
to 'Custom Matcher' but should be provided for clarity, e.g. 'GET /users/123?q=foo'
Implementation
void whenMatch(
CharlatanRequestMatcher requestMatcher,
CharlatanResponseBuilder responseBuilder, {
int statusCode = 200,
String? description,
}) {
_matchers.insert(
0,
CharlatanResponseDefinition(
description: description ?? 'Custom Matcher',
requestMatcher: requestMatcher,
responseBuilder: responseBuilder,
defaultStatusCode: statusCode,
),
);
}