diff --git a/server.go b/server.go index 2556086..f2caa39 100644 --- a/server.go +++ b/server.go @@ -146,6 +146,17 @@ func isTlsEnabled(fileout ...*string) bool { return true } +func registUnhandledPattern(serveMux ServerMuxInterface) { + defer func() { + recover() + }() + + serveMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + logger.Println("page not found :", r.URL.Path) + w.WriteHeader(http.StatusNotFound) + }) +} + // NewHTTPServer : func NewHTTPServerWithPort(serveMux ServerMuxInterface, port int) *Server { if isTlsEnabled() && port == 80 { @@ -155,6 +166,7 @@ func NewHTTPServerWithPort(serveMux ServerMuxInterface, port int) *Server { serveMux.HandleFunc(MakeHttpHandlerPattern("welcome"), welcomeHandler) serveMux.HandleFunc(MakeHttpHandlerPattern("lb_health_chceck"), healthCheckHandler) serveMux.HandleFunc(MakeHttpHandlerPattern("lb_health_check"), healthCheckHandler) + registUnhandledPattern(serveMux) server := &Server{ httpserver: &http.Server{Addr: addr, Handler: serveMux},