app.go: dump a webhook to the logging writer
This commit is contained in:
parent
8ec43e060c
commit
0fe6fca2b8
1 changed files with 34 additions and 0 deletions
34
app.go
Normal file
34
app.go
Normal 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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue