先直接上代码 r:=gin.Default() //注册中间件,使body可以重复读取 r.Use(func(contextgin.Context){ all,err:=context.GetRawData()//读取body的内容 iferr!=nil{ log.Fatal(err) } //重写GetBody方法,以便后续的其他操作 context.Request.GetBody=func()(io.ReadCloser,error){ context.Request.Body=io.NopCloser(bytes.NewBuffer(all)) ...

  i86oKZWg3QMr   2023年11月02日   56   0   0 Go
关注 更多

空空如也 ~ ~

粉丝 更多

空空如也 ~ ~