mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 07:55:06 +01:00 
			
		
		
		
	revert leftover notfoundhandler experiments
This commit is contained in:
		| @@ -257,7 +257,7 @@ func serverInit() { | |||||||
| 				router.PathPrefix("/img/").Handler(http.StripPrefix("/img/", http.FileServer(http.Dir("./var/img")))) | 				router.PathPrefix("/img/").Handler(http.StripPrefix("/img/", http.FileServer(http.Dir("./var/img")))) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", web.ServeFiles())) | 		router.PathPrefix("/").Handler(http.StripPrefix("/", web.ServeFiles())) | ||||||
| 	} else { | 	} else { | ||||||
| 		router.PathPrefix("/").Handler(http.FileServer(http.Dir(config.Keys.StaticFiles))) | 		router.PathPrefix("/").Handler(http.FileServer(http.Dir(config.Keys.StaticFiles))) | ||||||
| 	} | 	} | ||||||
| @@ -270,14 +270,14 @@ func serverInit() { | |||||||
| 		handlers.AllowedMethods([]string{"GET", "POST", "HEAD", "OPTIONS"}), | 		handlers.AllowedMethods([]string{"GET", "POST", "HEAD", "OPTIONS"}), | ||||||
| 		handlers.AllowedOrigins([]string{"*"}))) | 		handlers.AllowedOrigins([]string{"*"}))) | ||||||
|  |  | ||||||
| 	secured.NotFoundHandler = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { | 	// secured.NotFoundHandler = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { | ||||||
| 		page := web.Page{ | 	// 	page := web.Page{ | ||||||
| 			Title: "ClusterCockpit - Not Found", | 	// 		Title: "ClusterCockpit - Not Found", | ||||||
| 			Build: buildInfo, | 	// 		Build: buildInfo, | ||||||
| 		} | 	// 	} | ||||||
| 		rw.Header().Add("Content-Type", "text/html; charset=utf-8") | 	// 	rw.Header().Add("Content-Type", "text/html; charset=utf-8") | ||||||
| 		web.RenderTemplate(rw, "404.tmpl", &page) | 	// 	web.RenderTemplate(rw, "404.tmpl", &page) | ||||||
| 	}) | 	// }) | ||||||
|  |  | ||||||
| 	// secured.NotFoundHandler = http.HandlerFunc(http.NotFound) | 	// secured.NotFoundHandler = http.HandlerFunc(http.NotFound) | ||||||
| 	// router.NotFoundHandler = router.NewRoute().HandlerFunc(http.NotFound).GetHandler() | 	// router.NotFoundHandler = router.NewRoute().HandlerFunc(http.NotFound).GetHandler() | ||||||
| @@ -285,20 +285,20 @@ func serverInit() { | |||||||
| 	// printEndpoints(router) | 	// printEndpoints(router) | ||||||
| } | } | ||||||
|  |  | ||||||
| func printEndpoints(r *mux.Router) { | // func printEndpoints(r *mux.Router) { | ||||||
| 	r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error { | // 	r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error { | ||||||
| 		path, err := route.GetPathTemplate() | // 		path, err := route.GetPathTemplate() | ||||||
| 		if err != nil { | // 		if err != nil { | ||||||
| 			path = "nopath" | // 			path = "nopath" | ||||||
| 		} | // 		} | ||||||
| 		methods, err := route.GetMethods() | // 		methods, err := route.GetMethods() | ||||||
| 		if err != nil { | // 		if err != nil { | ||||||
| 			methods = append(methods, "nomethod") | // 			methods = append(methods, "nomethod") | ||||||
| 		} | // 		} | ||||||
| 		fmt.Printf("%v %s\n", methods, path) | // 		fmt.Printf("%v %s\n", methods, path) | ||||||
| 		return nil | // 		return nil | ||||||
| 	}) | // 	}) | ||||||
| } | // } | ||||||
|  |  | ||||||
| func serverStart() { | func serverStart() { | ||||||
| 	handler := handlers.CustomLoggingHandler(io.Discard, router, func(_ io.Writer, params handlers.LogFormatterParams) { | 	handler := handlers.CustomLoggingHandler(io.Discard, router, func(_ io.Writer, params handlers.LogFormatterParams) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user