-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gock): add gock.Observe to support inspection of the outgoing in…
…tercepted HTTP traffic
- Loading branch information
steinfletcher
committed
Oct 14, 2018
1 parent
db99161
commit 1cde9ef
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"gopkg.in/h2non/gock.v1" | ||
"net/http" | ||
) | ||
|
||
func main() { | ||
defer gock.Off() | ||
gock.Observe(gock.DumpRequest) | ||
|
||
gock.New("http://foo.com"). | ||
Post("/bar"). | ||
MatchType("json"). | ||
JSON(map[string]string{"foo": "bar"}). | ||
Reply(200) | ||
|
||
body := bytes.NewBuffer([]byte(`{"foo":"bar"}`)) | ||
http.Post("http://foo.com/bar", "application/json", body) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters