Skip to content

Commit 8afcd02

Browse files
committed
fix: add Post and Get()
1 parent cc1a06b commit 8afcd02

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

request.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ func NewRequest(options ...Option) *Request {
4646
return request
4747
}
4848

49-
func Init(method string) *Request {
50-
return NewRequest().ContentType("form").Method(method)
51-
}
52-
5349
func Post(uri string, payload interface{}) *Request {
54-
return Init(POST).Uri(uri).Body(payload)
50+
return NewRequest().Post(uri, payload)
5551
}
5652

5753
func Get(uri string, payload interface{}) *Request {
58-
return Init(GET).Uri(uri).Body(payload)
54+
return NewRequest().Get(uri, payload)
55+
}
56+
57+
func (r *Request) Post(uri string, payload interface{}) *Request {
58+
return r.ContentType(FORM).Method(POST).Uri(uri).Body(payload)
59+
}
60+
61+
func (r *Request) Get(uri string, payload interface{}) *Request {
62+
return r.ContentType(FORM).Method(GET).Uri(uri).Body(payload)
5963
}
6064

6165
func (r *Request) Send() (*Response, error) {

0 commit comments

Comments
 (0)