New error handling added to server and decorator module in data package

This commit is contained in:
Héctor Hurtado
2019-11-18 14:52:52 +01:00
parent edff842c3b
commit e4b3a4f718
4 changed files with 37 additions and 8 deletions
+2 -1
View File
@@ -20,6 +20,7 @@ import (
"net/http"
"github.com/BBVA/kapow/internal/server/model"
"github.com/BBVA/kapow/internal/server/srverrors"
"github.com/gorilla/mux"
)
@@ -39,7 +40,7 @@ func checkHandler(fn resourceHandler) func(http.ResponseWriter, *http.Request) {
if h, ok := Handlers.Get(handlerID); ok {
fn(w, r, h)
} else {
w.WriteHeader(http.StatusNotFound)
srverrors.WriteErrorResponse(http.StatusNotFound, "Handler ID Not Found", w)
}
}
}