mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Dismiss redundant function
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user