SendResponseWithMessage builds a response from the result and the provided message, sets the JSON header, and writes to the http.ResponseWriter.
(w http.ResponseWriter, result interface{}, message string, code int)
| 223 | // provided message, sets the JSON header, and writes to the |
| 224 | // http.ResponseWriter. |
| 225 | func SendResponseWithMessage(w http.ResponseWriter, result interface{}, message string, code int) error { |
| 226 | response := NewSuccessResponseWithMessage(result, message, code) |
| 227 | w.Header().Set("Content-Type", "application/json") |
| 228 | enc := json.NewEncoder(w) |
| 229 | err := enc.Encode(response) |
| 230 | return err |
| 231 | } |
no test coverage detected
searching dependent graphs…