SendResponse builds a response from the result, sets the JSON header, and writes to the http.ResponseWriter.
(w http.ResponseWriter, result interface{})
| 212 | // SendResponse builds a response from the result, sets the JSON |
| 213 | // header, and writes to the http.ResponseWriter. |
| 214 | func SendResponse(w http.ResponseWriter, result interface{}) error { |
| 215 | response := NewSuccessResponse(result) |
| 216 | w.Header().Set("Content-Type", "application/json") |
| 217 | enc := json.NewEncoder(w) |
| 218 | err := enc.Encode(response) |
| 219 | return err |
| 220 | } |
| 221 | |
| 222 | // SendResponseWithMessage builds a response from the result and the |
| 223 | // provided message, sets the JSON header, and writes to the |
searching dependent graphs…