alertmanager/examples/webhook/echo.go

25 lines
421 B
Go
Raw Normal View History

2016-08-19 10:13:02 +00:00
package main
import (
2016-09-05 09:17:28 +00:00
"bytes"
"encoding/json"
"fmt"
2016-08-19 10:13:02 +00:00
"io/ioutil"
"net/http"
)
func main() {
http.ListenAndServe(":5001", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
b, err := ioutil.ReadAll(r.Body)
if err != nil {
panic(err)
}
defer r.Body.Close()
2016-09-05 09:17:28 +00:00
var buf bytes.Buffer
if err := json.Indent(&buf, b, " >", " "); err != nil {
panic(err)
}
fmt.Println(buf.String())
2016-08-19 10:13:02 +00:00
}))
}