diff --git a/route/route.go b/route/route.go index 4a8bed0..d8965c8 100644 --- a/route/route.go +++ b/route/route.go @@ -19,6 +19,7 @@ func Route(db *gorm.DB) { http.HandleFunc("/birthday-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return } sessionID := helper.GenerateSessionID() @@ -36,6 +37,7 @@ func Route(db *gorm.DB) { log.Printf("%+v %+v response %+v", sessionID, module, err.Error()) w.WriteHeader(500) w.Write([]byte(err.Error())) + return } for _, v := range *data { @@ -69,6 +71,7 @@ func Route(db *gorm.DB) { http.HandleFunc("/workanniversary-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return } sessionID := helper.GenerateSessionID() @@ -85,6 +88,7 @@ func Route(db *gorm.DB) { log.Printf("%+v %+v response %+v", sessionID, module, err.Error()) w.WriteHeader(500) w.Write([]byte(err.Error())) + return } subject := "Work Anniversary 🎉" @@ -124,6 +128,7 @@ func Route(db *gorm.DB) { http.HandleFunc("/server-down-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return } sessionID := helper.GenerateSessionID() @@ -160,6 +165,7 @@ func Route(db *gorm.DB) { http.HandleFunc("/high-memory-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return } sessionID := helper.GenerateSessionID() @@ -196,13 +202,15 @@ func Route(db *gorm.DB) { http.Handle("/", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return } if r.URL.Path != "/" { w.WriteHeader(404) w.Write([]byte("What are you looking for?!")) - } else { - w.Write([]byte("Welcome!")) + return } + + w.Write([]byte("Welcome!")) })) }