RespondJSONObjectWithCode with specified code and object.
(w http.ResponseWriter, code int, obj interface{})
| 53 | |
| 54 | // RespondJSONObjectWithCode with specified code and object. |
| 55 | func RespondJSONObjectWithCode(w http.ResponseWriter, code int, obj interface{}) { |
| 56 | setCommonHeaders(w) |
| 57 | var err error |
| 58 | var jsonBytes []byte |
| 59 | if obj != nil { |
| 60 | jsonBytes, err = json.Marshal(obj) |
| 61 | } |
| 62 | writeJSONBytes(w, jsonBytes, err, code) |
| 63 | } |
| 64 | |
| 65 | // RespondBytesWithCode with specified code and bytes. |
| 66 | func RespondBytesWithCode(w http.ResponseWriter, code int, bs []byte) { |
no test coverage detected