1234567891011121314151617181920212223242526272829303132333435 |
- package dwmini
- import (
- "eta/eta_chart_lib/utils"
- "fmt"
- "io"
- "net/http"
- "strings"
- )
- func HttpPost(url, postData, token string) ([]byte, error) {
- body := io.NopCloser(strings.NewReader(postData))
- client := &http.Client{}
- req, err := http.NewRequest("POST", url, body)
- if err != nil {
- return nil, err
- }
- req.Header.Add("Authorization", token)
- req.Header.Set("Content-Type", "application/json")
- resp, err := client.Do(req)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
- b, err := io.ReadAll(resp.Body)
- fmt.Println("HttpPost:" + string(b))
- if utils.RunMode == "debug" {
- return b, err
- }
- str := string(b)
- str = strings.Trim(str, `"`)
- b = utils.DesBase64Decrypt([]byte(str), utils.ETA_MINI_DES_KEY)
- return b, err
- }
|