mirror of
https://framagit.org/fredix/drone-gotify
synced 2026-01-23 02:14:06 +00:00
some fix
This commit is contained in:
parent
44158debc4
commit
a31d1b63c9
1 changed files with 10 additions and 28 deletions
|
|
@ -1,42 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
url := os.Getenv("PLUGIN_GOTIFYENDPOINT") + "/message?token=" + os.Getenv("PLUGIN_GOTIFYTOKEN")
|
||||
token := os.Getenv("PLUGIN_GOTIFYTOKEN")
|
||||
endpoint := os.Getenv("PLUGIN_GOTIFYENDPOINT")
|
||||
title := os.Getenv("PLUGIN_GOTIFYTITLE")
|
||||
message := os.Getenv("message")
|
||||
priority := os.Getenv("PLUGIN_GOTIFYPRIORITY")
|
||||
|
||||
msg := struct {
|
||||
Title string `json:"title"`
|
||||
Message string `json:"message"`
|
||||
Priority string `json:"priority"`
|
||||
}{
|
||||
Title: os.Getenv("PLUGIN_GOTIFYTITLE"),
|
||||
Message: os.Getenv("message"),
|
||||
Priority: os.Getenv("PLUGIN_GOTIFYPRIORITY"),
|
||||
}
|
||||
|
||||
raw, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
//fmt.Printf("json : ", bytes.NewReader(raw))
|
||||
//os.Stdout.Write(raw)
|
||||
|
||||
resp, err := http.Post(url, "application/json", bytes.NewReader(raw))
|
||||
resp, err := http.PostForm(endpoint + "/message?token=" + token, url.Values{"message": {message}, "title": {title}, "priority": {priority}})
|
||||
if resp != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("err : ", err)
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue