writeHTTPMessage writes the given header and message to the HTTP response writer. Returns an error JSONResponse obtained through httputil.LogThenError if the writing failed, otherwise nil.
( w http.ResponseWriter, req *http.Request, message string, header int, )
| 197 | // writeHTTPMessage writes the given header and message to the HTTP response writer. |
| 198 | // Returns an error JSONResponse obtained through httputil.LogThenError if the writing failed, otherwise nil. |
| 199 | func writeHTTPMessage( |
| 200 | w http.ResponseWriter, req *http.Request, |
| 201 | message string, header int, |
| 202 | ) *util.JSONResponse { |
| 203 | w.WriteHeader(header) |
| 204 | _, err := w.Write([]byte(message)) |
| 205 | if err != nil { |
| 206 | util.GetLogger(req.Context()).WithError(err).Error("w.Write failed") |
| 207 | res := jsonerror.InternalServerError() |
| 208 | return &res |
| 209 | } |
| 210 | return nil |
| 211 | } |
no test coverage detected