1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

refactor: set body byte for http post request

This commit is contained in:
dudaodong
2022-02-25 15:31:39 +08:00
parent 85886cf618
commit f26477904e

View File

@@ -157,16 +157,12 @@ func setQueryParam(req *http.Request, reqUrl string, queryParam interface{}) err
func setBodyByte(req *http.Request, body interface{}) error {
if body != nil {
var bodyByte []byte
if body != nil {
switch v := body.(type) {
case []byte:
bodyByte = v
default:
return errors.New("body type should be []byte")
}
switch b := body.(type) {
case []byte:
req.Body = ioutil.NopCloser(bytes.NewReader(b))
default:
return errors.New("body type should be []byte")
}
req.Body = ioutil.NopCloser(bytes.NewReader(bodyByte))
}
return nil
}