Commit a31d1b63 authored by fredix's avatar fredix
Browse files

some fix

parent 44158deb
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)
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment