Created
November 22, 2017 09:15
-
-
Save drillbits/53925991fb9f815485a17e2b59328d33 to your computer and use it in GitHub Desktop.
Read http.Request.Body and rewind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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