Skip to content

Commit

Permalink
Merge pull request #82 from Alkorin/iffyRequestHost
Browse files Browse the repository at this point in the history
iffy: Allow to customize Host field
  • Loading branch information
rbeuque74 committed Oct 26, 2021
2 parents 06852c9 + bad7cb8 commit c4f8b2f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions iffy/iffy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Call struct {
QueryStr string
Body string
headers Headers
host string
respObject interface{}
checkers []Checker
}
Expand All @@ -42,6 +43,11 @@ func (c *Call) Headers(h Headers) *Call {
return c
}

func (c *Call) Host(h string) *Call {
c.host = h
return c
}

func (c *Call) Checkers(ch ...Checker) *Call {
c.checkers = ch
return c
Expand Down Expand Up @@ -97,6 +103,9 @@ func (it *Tester) Run() {
req.Header.Set(it.applyTemplate(k), it.applyTemplate(v))
}
}
if c.host != "" {
req.Host = c.host
}
w := httptest.NewRecorder()
it.r.ServeHTTP(w, req)
resp := w.Result()
Expand Down

0 comments on commit c4f8b2f

Please sign in to comment.