Issue with Second Body Retrieval in Go
After using the os.ReadAll(r.Body)
method, it is necessary to execute the following method to rewrite the body:
ctx.Request.Body = io.NopCloser(bytes.NewBuffer(signStrByte)) // Rewrite the body back, otherwise it cannot be retrieved elsewhere |
It has been observed in practice that using gin.Context.Bindxxx related methods also requires executing the above method to rewrite the body.
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment