Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New custom predicate of matcher API.
In the previous API, the
SinglePredicate
could be used to composite various matching conditions. However, it's very flexible but isn't easy to use. Especially if there are some common matching compositions that will be used frequently, for example, the headers matching.This PR introduced a new
CustomPredicate
to present an custom matching condition. This new predicate type will take the protocol-specific data as input, and a bool as output. All the input and match logics are defined by the extension config.This new type could be used when there are some common matching compositions. We can define a custom predicate as a composition of multiple different but releated matching conditions.
In addition, any protocol-specific data matching or non-string data matching could use this new
CustomPredicate
.Take the headers match as an example. If there are three headers need to match, then the config in previous API would be:
And with the new API, the API could be:
Based on the new API, the configuration will be more simple and easy to read or manage.