Closed cakejelly closed 2 years ago
True. It is somehow redundant and can lead to confusion. I believe we should keep MatchType
and simply pass the MIME type to match to supportedType
function.
@h2non makes sense and agreed, I think it's much cleaner to just keep MatchType. Pushed a new commit with your suggestion, please take another look when you get the chance 🙃 thanks.
Thank you!
PR to add the custom body type matcher that was proposed in https://github.com/h2non/gock/issues/87
The logic is pretty simple - If a user passes a non-empty mime type to the BodyType function, then the
Content-Type
header on the http request must be the same for there to be a match. If there's no mime type passed then it falls back to the the existing logic of checking against the hardcoded list of supported mime types.One thing I'm a bit unsure of - I discovered
MatchType
and now I feel like adding this additional method will be confusing to people, since there will be two separate methods for matching based on theContent-Type
header but the behaviour is different.@h2non Any thoughts on this?