fix
This commit is contained in:
34
utils/curl/http_curl.go
Normal file
34
utils/curl/http_curl.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package curl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 接口请求
|
||||
func ApiCall(url, method string, header map[string]string, postData []byte, 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")
|
||||
}
|
||||
if url == "" {
|
||||
return nil, errors.New("request url can`t be empty")
|
||||
}
|
||||
client := &http.Client{}
|
||||
if timeOut <= 0 {
|
||||
client.Timeout = time.Second * 15
|
||||
} else {
|
||||
client.Timeout = timeOut
|
||||
}
|
||||
requestHandle, err := http.NewRequest(method, url, bytes.NewReader(postData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range header {
|
||||
requestHandle.Header.Set(k, v)
|
||||
}
|
||||
return client.Do(requestHandle)
|
||||
}
|
||||
@@ -14,9 +14,9 @@ type RenderImageReqMsg struct {
|
||||
type RenderData struct {
|
||||
TemplateTagId int64 `json:"template_tag_id"` //模板标签id
|
||||
ProductId int64 `json:"product_id"` //产品id
|
||||
Logo string `json:"logo"`
|
||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值)
|
||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
}
|
||||
|
||||
// websocket发送渲染完的数据
|
||||
|
||||
Reference in New Issue
Block a user