first commit
This commit is contained in:
44
handwork/send.go
Normal file
44
handwork/send.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package handwork
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Sendhand(i bool) {
|
||||
if !i {
|
||||
return
|
||||
}
|
||||
url := conf.Ip + ":" + conf.Port
|
||||
data := conf.Key
|
||||
resp, err := http.Post(url, "application/x-www-form-urlencoded", strings.NewReader(data))
|
||||
if err != nil {
|
||||
fmt.Println("错误请求:", err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
fmt.Println("错误的返回请求:", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("状态码:", resp.Status)
|
||||
fmt.Println("返回body:", string(body))
|
||||
|
||||
var analydata map[string]string
|
||||
err = json.Unmarshal(body, &analydata)
|
||||
if err != nil {
|
||||
fmt.Println("JSON解析错误:", err)
|
||||
return
|
||||
}
|
||||
|
||||
if analydata["type"] == "" {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user