diff --git a/examples/webhook/echo.go b/examples/webhook/echo.go index 26ea646a..43ccf1b4 100644 --- a/examples/webhook/echo.go +++ b/examples/webhook/echo.go @@ -1,19 +1,24 @@ package main import ( + "bytes" + "encoding/json" + "fmt" "io/ioutil" - "log" "net/http" ) func main() { http.ListenAndServe(":5001", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - log.Println("received request:", r.Header) b, err := ioutil.ReadAll(r.Body) if err != nil { panic(err) } defer r.Body.Close() - log.Println("request body:", string(b)) + var buf bytes.Buffer + if err := json.Indent(&buf, b, " >", " "); err != nil { + panic(err) + } + fmt.Println(buf.String()) })) }