35 lines
544 B
Go
35 lines
544 B
Go
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")
|
|
}
|
|
|