[skip ci] gofmt
This commit is contained in:
parent
09c4d66797
commit
f33dc4d866
|
@ -1,12 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"encoding/json"
|
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gotify/go-api-client/auth"
|
"github.com/gotify/go-api-client/auth"
|
||||||
|
@ -21,13 +21,13 @@ type POSTData struct {
|
||||||
|
|
||||||
type Alert struct {
|
type Alert struct {
|
||||||
Annotations Annotations `json:annotations`
|
Annotations Annotations `json:annotations`
|
||||||
Labels Labels `json:labels`
|
Labels Labels `json:labels`
|
||||||
Status string `json:status`
|
Status string `json:status`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Annotations struct {
|
type Annotations struct {
|
||||||
Description string `json:description`
|
Description string `json:description`
|
||||||
Title string `json:title`
|
Title string `json:title`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Labels struct {
|
type Labels struct {
|
||||||
|
@ -37,7 +37,7 @@ type Labels struct {
|
||||||
func main() {
|
func main() {
|
||||||
gotifyURL := os.Getenv("GOTIFY_URL")
|
gotifyURL := os.Getenv("GOTIFY_URL")
|
||||||
|
|
||||||
http.HandleFunc("/alert", func (w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/alert", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
http.Error(w, "405 Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "405 Method not allowed", http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
|
@ -80,8 +80,8 @@ func main() {
|
||||||
|
|
||||||
params := message.NewCreateMessageParams()
|
params := message.NewCreateMessageParams()
|
||||||
params.Body = &models.MessageExternal{
|
params.Body = &models.MessageExternal{
|
||||||
Title: title.String(),
|
Title: title.String(),
|
||||||
Message: alert.Annotations.Description,
|
Message: alert.Annotations.Description,
|
||||||
}
|
}
|
||||||
_, err = client.Message.CreateMessage(params, auth.TokenAuth(applicationToken))
|
_, err = client.Message.CreateMessage(params, auth.TokenAuth(applicationToken))
|
||||||
|
|
||||||
|
|
Reference in a new issue