fix
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package curl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 接口请求
|
||||
func ApiCall(url, method string, header map[string]string, postData []byte, timeOut time.Duration) (rsp *http.Response, err error) {
|
||||
func ApiCall(url, method string, header map[string]string, body io.Reader, timeOut time.Duration) (rsp *http.Response, err error) {
|
||||
method = strings.ToUpper(method)
|
||||
if method != "GET" && method != "POST" && method != "PUT" && method != "DELETE" {
|
||||
return nil, errors.New("invalid http method")
|
||||
@@ -23,7 +23,7 @@ func ApiCall(url, method string, header map[string]string, postData []byte, time
|
||||
} else {
|
||||
client.Timeout = timeOut
|
||||
}
|
||||
requestHandle, err := http.NewRequest(method, url, bytes.NewReader(postData))
|
||||
requestHandle, err := http.NewRequest(method, url, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user