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
+4 -1
View File
@@ -20,6 +20,7 @@ import (
"log"
"net/http"
"github.com/BBVA/kapow/internal/server/srverrors"
"github.com/gorilla/mux"
)
@@ -36,7 +37,9 @@ func configRouter(rs []routeSpec) (r *mux.Router) {
}
r.HandleFunc(
"/handlers/{handlerID}/{resource:.*}",
func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusBadRequest) })
func(w http.ResponseWriter, r *http.Request) {
srverrors.WriteErrorResponse(http.StatusBadRequest, "Invalid Resource Path", w)
})
return r
}