github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/body.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "github.com/gogf/gf/frame/g" 6 "github.com/gogf/gf/net/ghttp" 7 "io/ioutil" 8 ) 9 10 func main() { 11 s := g.Server() 12 s.SetIndexFolder(true) 13 s.BindHandler("/", func(r *ghttp.Request) { 14 body1 := r.GetBody() 15 body2, _ := ioutil.ReadAll(r.Body) 16 fmt.Println(body1) 17 fmt.Println(body2) 18 r.Response.Write("hello world") 19 }) 20 s.SetPort(8999) 21 s.Run() 22 }