Skip to content

Instantly share code, notes, and snippets.

@kyleterry
Created May 12, 2020 19:01
Show Gist options
  • Save kyleterry/0543b882facd2efea51b7568885d9b23 to your computer and use it in GitHub Desktop.
Save kyleterry/0543b882facd2efea51b7568885d9b23 to your computer and use it in GitHub Desktop.
// SetJSONBody is used to set a request body that is a JSON-encoded value.
func (r *Request) SetJSONBody(val interface{}) error {
buf, err := json.Marshal(val)
if err != nil {
return err
}
r.Obj = val
r.BodyBytes = buf
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment