MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / SendMessage

Function SendMessage

agent/utils/bark/bark.go:15–46  ·  view source on GitHub ↗
(url string, title string, body string, transport *http.Transport)

Source from the content-addressed store, hash-verified

13}
14
15func SendMessage(url string, title string, body string, transport *http.Transport) error {
16 msg := BarkMessage{
17 Title: title,
18 Body: body,
19 }
20 data, err := json.Marshal(msg)
21 if err != nil {
22 return err
23 }
24
25 client := &http.Client{
26 Transport: transport,
27 }
28
29 req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
30 if err != nil {
31 return err
32 }
33 req.Header.Set("Content-Type", "application/json; charset=utf-8")
34
35 resp, err := client.Do(req)
36 if err != nil {
37 return err
38 }
39 defer resp.Body.Close()
40
41 if resp.StatusCode != http.StatusOK {
42 return fmt.Errorf("bark push failed with status code %d", resp.StatusCode)
43 }
44
45 return nil
46}

Callers

nothing calls this directly

Calls 2

CloseMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected