Skip to content

Instantly share code, notes, and snippets.

@drillbits
Created November 22, 2017 09:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drillbits/53925991fb9f815485a17e2b59328d33 to your computer and use it in GitHub Desktop.
Save drillbits/53925991fb9f815485a17e2b59328d33 to your computer and use it in GitHub Desktop.
Read http.Request.Body and rewind
func readRewindRequest(r *http.Request) []byte {
var b []byte
if r.Body != nil {
b, _ = ioutil.ReadAll(r.Body)
}
r.Body = ioutil.NopCloser(bytes.NewBuffer(b))
return b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment