Skip to content

Commit

Permalink
feat: requests add JSON Body
Browse files Browse the repository at this point in the history
  • Loading branch information
yinheli committed Jul 7, 2021
1 parent 93e6416 commit 8e4bb9c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/requests/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func (t *requests) Form(form url.Values) *requests {
return t
}

func (t *requests) JSONBody(data interface{}) *requests {
b, _ := json.Marshal(data)
return t.ContentType(ContentTypeJSON).Data(b)
}

func (t *requests) Body(body io.Reader) *requests {
t.body = body
return t
Expand Down

0 comments on commit 8e4bb9c

Please sign in to comment.