fix
This commit is contained in:
parent
04b8e5b03b
commit
50c23df124
|
@ -6,16 +6,21 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PostLog(data any, path string) (resp *http.Response, err error) {
|
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)
|
jsonBytes, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", path, bytes.NewBuffer(jsonBytes))
|
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(jsonBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
resp, err = client.Do(req)
|
resp, err = client.Do(req)
|
|
@ -0,0 +1,18 @@
|
||||||
|
package oplog
|
||||||
|
|
||||||
|
type LogItem struct {
|
||||||
|
OpID uint `json:"op_id"`
|
||||||
|
OpName string `json:"op_name"`
|
||||||
|
OpType string `json:"op_type"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
Type_Login string = "login"
|
||||||
|
Type_Logout string = "logout"
|
||||||
|
Type_Register string = "register"
|
||||||
|
Type_Update string = "update"
|
||||||
|
Type_Delete string = "delete"
|
||||||
|
Type_Query string = "query"
|
||||||
|
Type_Other string = "other"
|
||||||
|
)
|
Loading…
Reference in New Issue