Add basic 404 page

This commit is contained in:
Gianluca Arbezzano 2017-03-26 22:33:26 +01:00
parent 4cdb55a18d
commit 3cea6bb8ba
2 changed files with 15 additions and 0 deletions

14
api/notfound.go Normal file
View File

@ -0,0 +1,14 @@
package api
import (
"net/http"
"github.com/Sirupsen/logrus"
)
type NotFound struct{}
func (n NotFound) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404)
logrus.Infof("%s %s not found.", r.Method, r.URL.String())
}

View File

@ -12,5 +12,6 @@ func GetRouter(core core.Core, eventChannel chan *logrus.Entry) *mux.Router {
r.HandleFunc("/autoscaler", AutoscalerList(core.Autoscalers)).Methods("GET")
r.HandleFunc("/health", Health()).Methods("GET")
r.HandleFunc("/events", Events(eventChannel)).Methods("GET")
r.NotFoundHandler = NotFound{}
return r
}