Default handlers for NotFound and MethodNotAllowed returning json reason added to control y data servers

This commit is contained in:
Héctor Hurtado committed 2020-04-07 12:22:15 +02:00
1 parent 4988c48e03
commit e1788b2874
3 files changed
+33 -4

No files matched your search

+9
View File
@@ -42,6 +42,15 @@ func configRouter(rs []routeSpec) (r *mux.Router) {
func(w http.ResponseWriter, r *http.Request) {
httperror.ErrorJSON(w, "Invalid Resource Path", http.StatusBadRequest)
})
r.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, h *http.Request) {
httperror.ErrorJSON(w, "Data server: Not found", http.StatusNotFound)
})
r.MethodNotAllowedHandler = http.HandlerFunc(func(w http.ResponseWriter, h *http.Request) {
httperror.ErrorJSON(w, "Data server: Method not allowed", http.StatusMethodNotAllowed)
})
return r
}