Request Matchers
This section describes matcher functions that enable developers to implement custom matchers. These matchers execute user-defined code to determine if a request meets specific criteria.
is_true
Adds a custom matcher for expected HTTP requests. If this function returns true, the request is considered a match, and the mock server will respond to the request (given all other criteria are also met).
You can use this function to create custom expectations for your mock server based on any aspect
of the HttpMockRequest
object.
Parameters
matcher
: A function that takes a reference to anHttpMockRequest
and returns a boolean indicating whether the request matches.
Example
Returns
When
: Returns the modified When
object with the new custom matcher added to the expectations.
is_false
Adds a custom matcher for expected HTTP requests. If this function returns false, the request is considered a match, and the mock server will respond to the request (given all other criteria are also met).
You can use this function to create custom expectations for your mock server based on any aspect
of the HttpMockRequest
object.
Parameters
matcher
: A function that takes a reference to anHttpMockRequest
and returns a boolean indicating whether the request matches.
Example
Returns
When
: Returns the modified When
object with the new custom matcher added to the expectations.