Open frncmx opened 4 years ago
Note, the POST version works ofc:
const url = "http://example.com"
gock.New(url).Post("").BodyString("foo")
if _, err := http.Post(url,"text/plain",strings.NewReader("foo")); err != nil {
log.Fatal(err)
}
The body matcher should be used in pull-only HTTP verbs such as GET
or HEAD
.
I'm quite busy, but happy to merge a PR.
I'm new to
gock
and I'm fiddling with it to get some hands-on experience. This is when I got a panic and 1st it wasn't trivial what's going on. As I understand it now: I got apanic
because I set an HTTP body matcher on a GET request. Could we maybe improve the user experience, maybe just by panicking sooner, i.e., when setting the body matcher?Here is how to reproduce the panic:
The panic itself:
I think the root cause might be the same with https://github.com/h2non/gock/issues/70