SetJSONBody is used to set a request body that is a JSON-encoded value.
(val interface{})
| 45 | |
| 46 | // SetJSONBody is used to set a request body that is a JSON-encoded value. |
| 47 | func (r *Request) SetJSONBody(val interface{}) error { |
| 48 | buf, err := json.Marshal(val) |
| 49 | if err != nil { |
| 50 | return err |
| 51 | } |
| 52 | |
| 53 | r.Obj = val |
| 54 | r.BodyBytes = buf |
| 55 | return nil |
| 56 | } |
| 57 | |
| 58 | // ResetJSONBody is used to reset the body for a redirect |
| 59 | func (r *Request) ResetJSONBody() error { |