Dismiss redundant function

This commit is contained in:
Denis Makogon
2017-09-30 00:11:25 +03:00
parent 3fb040f293
commit 0316cd90a1

View File

@@ -87,20 +87,15 @@ func (h *JSONProtocol) Dispatch(w io.Writer, req *http.Request) error {
} }
func respondWithError(w io.Writer, err error) error { func respondWithError(w io.Writer, err error) error {
writeResponse(w, []byte(err.Error()), http.StatusInternalServerError) errMsg := []byte(err.Error())
return err statusCode := http.StatusInternalServerError
}
func writeResponse(w io.Writer, b []byte, statusCode int) {
if rw, ok := w.(http.ResponseWriter); ok { if rw, ok := w.(http.ResponseWriter); ok {
rw.WriteHeader(statusCode) rw.WriteHeader(statusCode)
_, err := rw.Write(b) // TODO timeout rw.Write(errMsg)
if err != nil {
err = fmt.Errorf("unable to write JSON response object: %s", err.Error())
respondWithError(w, err)
}
} else { } else {
// logs can just copy the full thing in there, headers and all. // logs can just copy the full thing in there, headers and all.
w.Write(b) // TODO timeout w.Write(errMsg)
} }
return err
} }