From d10b130dbc33f51a852e484cc954b3fa10aac856 Mon Sep 17 00:00:00 2001 From: Peter Aba Date: Sun, 8 Apr 2018 15:28:51 +0200 Subject: [PATCH] Review fixes --- api.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 72fccc2..98268ed 100644 --- a/api.go +++ b/api.go @@ -47,7 +47,7 @@ func RenderJSON(w http.ResponseWriter, code int, value interface{}) { w.WriteHeader(code) err := json.NewEncoder(w).Encode(value) if err != nil { - http.Error(w, err.Error(), code) + http.Error(w, err.Error(), http.StatusInternalServerError) return } } @@ -117,7 +117,9 @@ func DynamicEndpoint(w http.ResponseWriter, r *http.Request) { RenderJSON(w, code, eVal) return } - RenderJSON(w, http.StatusNotFound, NewResponse("apidemic: "+vars["endpoint"]+" has no "+r.Method+" endpoint")) + + responseText := fmt.Sprintf("apidemic: %s has no %s endpoint", vars["endpoint"], r.Method) + RenderJSON(w, http.StatusNotFound, NewResponse(responseText) } // NewResponse helper for response JSON message