note found handler

This commit is contained in:
emile 2015-09-16 22:41:01 +02:00
parent 2d645c83a6
commit 7b96decf17
2 changed files with 7 additions and 6 deletions

View file

@ -170,7 +170,8 @@ func main() {
} }
func notFoundHandler(w http.ResponseWriter, r *http.Request) { func notFoundHandler(w http.ResponseWriter, r *http.Request) {
templatesRenderer.HTML(w, http.StatusNotFound, "notFound", nil) http.NotFound(w, r)
//templatesRenderer.HTML(w, http.StatusNotFound, "notFound", nil)
} }
func LoadDefaultConfig(gloablConfiguration *GlobalConfiguration) *mux.Router { func LoadDefaultConfig(gloablConfiguration *GlobalConfiguration) *mux.Router {

10
web.go
View file

@ -68,7 +68,7 @@ func GetBackendHandler(rw http.ResponseWriter, r *http.Request) {
if backend, ok := currentConfiguration.Backends[id]; ok { if backend, ok := currentConfiguration.Backends[id]; ok {
templatesRenderer.JSON(rw, http.StatusOK, backend) templatesRenderer.JSON(rw, http.StatusOK, backend)
}else{ }else{
templatesRenderer.JSON(rw, http.StatusNotFound, nil) http.NotFound(rw, r)
} }
} }
@ -82,7 +82,7 @@ func GetFrontendHandler(rw http.ResponseWriter, r *http.Request) {
if frontend, ok := currentConfiguration.Frontends[id]; ok { if frontend, ok := currentConfiguration.Frontends[id]; ok {
templatesRenderer.JSON(rw, http.StatusOK, frontend) templatesRenderer.JSON(rw, http.StatusOK, frontend)
}else{ }else{
templatesRenderer.JSON(rw, http.StatusNotFound, nil) http.NotFound(rw, r)
} }
} }
@ -92,7 +92,7 @@ func GetServersHandler(rw http.ResponseWriter, r *http.Request) {
if backend, ok := currentConfiguration.Backends[backend]; ok { if backend, ok := currentConfiguration.Backends[backend]; ok {
templatesRenderer.JSON(rw, http.StatusOK, backend.Servers) templatesRenderer.JSON(rw, http.StatusOK, backend.Servers)
}else{ }else{
templatesRenderer.JSON(rw, http.StatusNotFound, nil) http.NotFound(rw, r)
} }
} }
@ -104,9 +104,9 @@ func GetServerHandler(rw http.ResponseWriter, r *http.Request) {
if server, ok := backend.Servers[server]; ok { if server, ok := backend.Servers[server]; ok {
templatesRenderer.JSON(rw, http.StatusOK, server) templatesRenderer.JSON(rw, http.StatusOK, server)
}else{ }else{
templatesRenderer.JSON(rw, http.StatusNotFound, nil) http.NotFound(rw, r)
} }
}else{ }else{
templatesRenderer.JSON(rw, http.StatusNotFound, nil) http.NotFound(rw, r)
} }
} }