This commit is contained in:
teddy
2025-04-21 11:11:48 +07:00
parent c4e963e8f5
commit 4bfb6b4861

View File

@@ -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!"))
}))
}