From 8e4bb9ca456369f9599abfd90419b7905d16490d Mon Sep 17 00:00:00 2001 From: yinheli Date: Wed, 7 Jul 2021 18:24:50 +0800 Subject: [PATCH] feat: requests add JSON Body --- pkg/requests/requests.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/requests/requests.go b/pkg/requests/requests.go index da3c3af..07e19cc 100644 --- a/pkg/requests/requests.go +++ b/pkg/requests/requests.go @@ -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