app.go: dump a webhook to the logging writer

This commit is contained in:
Vincent Batts 2020-08-05 14:57:34 -04:00
parent 8ec43e060c
commit 0fe6fca2b8
Signed by: vbatts
GPG Key ID: 10937E57733F1362
1 changed files with 34 additions and 0 deletions

34
app.go Normal file
View File

@ -0,0 +1,34 @@
package main
import (
"io"
"fmt"
//"github.com/davecgh/go-spew/spew"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.POST("/testing", func(c *gin.Context) {
i, err := io.Copy(gin.DefaultWriter, c.Request.Body)
if err != nil {
c.Request.Body.Close()
}
if i > 0 {
fmt.Fprintf(gin.DefaultWriter, "\n")
}
c.String(200, "pong")
})
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}