From 0fe6fca2b8ed0be7933020418d966346a536e6c1 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 5 Aug 2020 14:57:34 -0400 Subject: [PATCH] app.go: dump a webhook to the logging writer --- app.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app.go diff --git a/app.go b/app.go new file mode 100644 index 0000000..178cb41 --- /dev/null +++ b/app.go @@ -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") +} +