update:
This commit is contained in:
@@ -19,6 +19,7 @@ func Route(db *gorm.DB) {
|
|||||||
http.HandleFunc("/birthday-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/birthday-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodGet {
|
if r.Method != http.MethodGet {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionID := helper.GenerateSessionID()
|
sessionID := helper.GenerateSessionID()
|
||||||
@@ -36,6 +37,7 @@ func Route(db *gorm.DB) {
|
|||||||
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range *data {
|
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) {
|
http.HandleFunc("/workanniversary-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodGet {
|
if r.Method != http.MethodGet {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionID := helper.GenerateSessionID()
|
sessionID := helper.GenerateSessionID()
|
||||||
@@ -85,6 +88,7 @@ func Route(db *gorm.DB) {
|
|||||||
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
subject := "Work Anniversary 🎉"
|
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) {
|
http.HandleFunc("/server-down-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodGet {
|
if r.Method != http.MethodGet {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionID := helper.GenerateSessionID()
|
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) {
|
http.HandleFunc("/high-memory-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodGet {
|
if r.Method != http.MethodGet {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionID := helper.GenerateSessionID()
|
sessionID := helper.GenerateSessionID()
|
||||||
@@ -196,13 +202,15 @@ func Route(db *gorm.DB) {
|
|||||||
http.Handle("/", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
http.Handle("/", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodGet {
|
if r.Method != http.MethodGet {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.URL.Path != "/" {
|
if r.URL.Path != "/" {
|
||||||
w.WriteHeader(404)
|
w.WriteHeader(404)
|
||||||
w.Write([]byte("What are you looking for?!"))
|
w.Write([]byte("What are you looking for?!"))
|
||||||
} else {
|
return
|
||||||
w.Write([]byte("Welcome!"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Write([]byte("Welcome!"))
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user