Compare commits

...

4 Commits

Author SHA1 Message Date
zhaoxiaorong
4b73f086b1 dev oplog 2025-04-11 18:14:07 +08:00
zhaoxiaorong
c08950c10a fix 2025-04-11 18:06:08 +08:00
zhaoxiaorong
d691648916 fix 2025-04-11 17:53:50 +08:00
zhaoxiaorong
8060cdb508 fix 2025-04-11 17:50:06 +08:00

View File

@@ -1,32 +1,14 @@
package oplog
import (
"bytes"
"encoding/json"
"net/http"
"git.apinb.com/bsm-sdk/core/utils"
)
func New(endpoint string, data []*LogItem) error {
go PostLog(data, endpoint)
return nil
}
func PostLog(data []*LogItem, endpoint string) (resp *http.Response, err error) {
jsonBytes, err := json.Marshal(data)
if err != nil {
return nil, err
}
func New(endpoint string, data []*LogItem) {
jsonBytes, _ := json.Marshal(data)
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(jsonBytes))
if err != nil {
return nil, err
}
go utils.HttpPost(endpoint, nil, jsonBytes)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err = client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
return
}