This commit is contained in:
teddy
2025-04-29 10:51:39 +07:00
parent b6ed73248b
commit cce3b3e1f1
2 changed files with 29 additions and 9 deletions

View File

@@ -15,8 +15,8 @@ import (
"gorm.io/gorm"
)
func Route(db *gorm.DB) {
http.HandleFunc("/birthday-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
func Route(db *gorm.DB, mux *http.ServeMux) {
mux.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
@@ -68,7 +68,7 @@ func Route(db *gorm.DB) {
w.Write([]byte("success"))
}))
http.HandleFunc("/workanniversary-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
mux.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
@@ -125,7 +125,7 @@ func Route(db *gorm.DB) {
w.Write([]byte("success"))
}))
http.HandleFunc("/server-down-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
mux.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
@@ -162,7 +162,7 @@ func Route(db *gorm.DB) {
w.Write([]byte("success"))
}))
http.HandleFunc("/high-memory-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
mux.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
@@ -199,7 +199,7 @@ func Route(db *gorm.DB) {
w.Write([]byte("success"))
}))
http.HandleFunc("/send-email", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/send-email", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
@@ -257,7 +257,7 @@ func Route(db *gorm.DB) {
w.Write([]byte("success"))
}))
http.Handle("/", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
mux.Handle("/", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return