MCPcopy Create free account
hub / github.com/feiyu563/PrometheusAlert / PostToFeiShu

Function PostToFeiShu

controllers/feishu.go:37–71  ·  view source on GitHub ↗
(title, text, Fsurl, logsign string)

Source from the content-addressed store, hash-verified

35}
36
37func PostToFeiShu(title, text, Fsurl, logsign string) string {
38 u := FSMessage{Title: title, Text: text}
39
40 b := new(bytes.Buffer)
41 json.NewEncoder(b).Encode(u)
42 logs.Info(logsign, "[feishu]", b)
43 var tr *http.Transport
44 if proxyUrl := beego.AppConfig.String("proxy"); proxyUrl != "" {
45 proxy := func(_ *http.Request) (*url.URL, error) {
46 return url.Parse(proxyUrl)
47 }
48 tr = &http.Transport{
49 TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
50 Proxy: proxy,
51 }
52 } else {
53 tr = &http.Transport{
54 TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
55 }
56 }
57 client := &http.Client{Transport: tr}
58 res, err := client.Post(Fsurl, "application/json", b)
59 if err != nil {
60 logs.Error(logsign, "[feishu]", err.Error())
61 }
62 defer res.Body.Close()
63 result, err := ioutil.ReadAll(res.Body)
64 if err != nil {
65 logs.Error(logsign, "[feishu]", err.Error())
66 }
67 models.AlertToCounter.WithLabelValues("feishu").Add(1)
68 ChartsJson.Feishu += 1
69 logs.Info(logsign, "[feishu]", string(result))
70 return string(result)
71}
72
73type Conf struct {
74 WideScreenMode bool `json:"wide_screen_mode"`

Callers 1

PostToFSFunction · 0.85

Calls 2

stringFunction · 0.85
PostMethod · 0.80

Tested by

no test coverage detected