Skip to content

Commit a6fdfac

Browse files
authored
- Add ability for users to define their own match rule(s) (#30)
1 parent 95e3801 commit a6fdfac

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Next Release
44

5+
- New `byCustomRule` function to allow users to define their own matching rule when finding a matching interaction in a cassette
56
- Improve error messages when a matching interaction is not found (human-readable error messages)
67
- Fix bug where the base URL matching rule was not comparing the scheme, host, and port of the request URL properly
78

src/main/java/com/easypost/easyvcr/MatchRules.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,18 @@ public MatchRules byMethod() {
248248
return this;
249249
}
250250

251+
/**
252+
* Add a rule to compare two requests by a custom rule.
253+
* @param rule A BiFunction that accepts two Request instances and returns true if they match, false otherwise.
254+
* The first parameter is the current in-flight request,
255+
* the second parameter is the recorded request from the current cassette.
256+
* @return This MatchRules factory.
257+
*/
258+
public MatchRules byCustomRule(BiFunction<Request, Request, Boolean> rule) {
259+
by(rule);
260+
return this;
261+
}
262+
251263
/**
252264
* Execute rules to determine if the received request matches the recorded request.
253265
*

0 commit comments

Comments
 (0)