Skip to content

Instantly share code, notes, and snippets.

@f0ster
Created July 6, 2016 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f0ster/ea3b4832b7ca677abc5346ebdf4bfb74 to your computer and use it in GitHub Desktop.
Save f0ster/ea3b4832b7ca677abc5346ebdf4bfb74 to your computer and use it in GitHub Desktop.
// Read the content
var bodyBytes []byte
if r.Request.Body != nil {
bodyBytes, _ = ioutil.ReadAll(r.Request.Body)
}
// Restore the io.ReadCloser to its original state
r.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
// Use the content
requestMetrics.Body = string(bodyBytes)
b, _ := json.Marshal(requestMetrics)
// Convert bytes to string.
requestLogger.Println(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment