post echo request

This commit is contained in:
cyrus 2024-05-24 20:53:34 +00:00
parent 00e86f3b06
commit 0b4199c798

14
main.go
View File

@ -1,6 +1,11 @@
package main package main
import "github.com/gin-gonic/gin" import (
"bytes"
"fmt"
"github.com/gin-gonic/gin"
)
func main() { func main() {
router := gin.Default() router := gin.Default()
@ -9,5 +14,12 @@ func main() {
"version": "0.0.1", "version": "0.0.1",
}) })
}) })
router.POST("/echo", func(c *gin.Context) {
buf := new(bytes.Buffer)
buf.ReadFrom(c.Request.Body)
data := buf.String()
fmt.Println(data)
})
router.Run("0.0.0.0:80") // listen and serve on 0.0.0.0:8080 router.Run("0.0.0.0:80") // listen and serve on 0.0.0.0:8080
} }