h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽

Home Page:https://pkg.go.dev/github.com/h2non/gock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom response function

h2non opened this issue · comments

commented

Instead of Reply(code), use:

gock.New("https://google.com").
  Get("/foo").
  ReplyFunc(func (r *gock.Response) {
    r.StatusCode = 200
    r.Header.Set("foo", "bar")
  })
commented

Done and shipped in 0.1.5.