respond static method
void
respond(})
Register a URL pattern with a mock response.
Patterns support:
*matches any single path segment**matches any number of path segments
Example:
NyMockApi.respond('/users/*', {'id': 1}); // matches /users/1, /users/abc
NyMockApi.respond('/api/**', {'data': []}); // matches /api/v1/users/1
Implementation
static void respond(
String pattern,
dynamic response, {
int statusCode = 200,
String method = 'GET',
Map<String, dynamic>? headers,
Duration? delay,
}) {
_urlPatterns.add(
_UrlPattern(
pattern: pattern,
response: response,
statusCode: statusCode,
method: method.toUpperCase(),
headers: headers,
delay: delay,
),
);
}