update
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"email-notification/app"
|
||||
"email-notification/helper"
|
||||
"email-notification/middleware"
|
||||
"email-notification/model"
|
||||
@@ -16,6 +15,10 @@ import (
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
sessionID := helper.GenerateSessionID()
|
||||
module := "BIRTHDAY NOTIFICATION"
|
||||
log.Printf("%+v %+v request %+v", sessionID, module, nil)
|
||||
@@ -48,7 +51,7 @@ func Route(db *gorm.DB) {
|
||||
|
||||
go func(v model.Birthday) {
|
||||
log.Printf("%+v %+v SENDING EMAIL TO %+v", sessionID, module, v.Email)
|
||||
err := app.SendEmail(sendTo, sendTo, "", subject, "", htmlString)
|
||||
err := helper.SendEmail(sendTo, sendTo, "", subject, "", htmlString)
|
||||
if err != nil {
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
||||
} else {
|
||||
@@ -62,6 +65,10 @@ 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)
|
||||
}
|
||||
|
||||
sessionID := helper.GenerateSessionID()
|
||||
module := "WORKANNIVERSARY NOTIFICATION"
|
||||
log.Printf("%+v %+v request %+v", sessionID, module, nil)
|
||||
@@ -99,7 +106,7 @@ func Route(db *gorm.DB) {
|
||||
|
||||
go func(v model.Workanniversary) {
|
||||
log.Printf("%+v %+v SENDING EMAIL TO %+v", sessionID, module, v.Email)
|
||||
err := app.SendEmail(sendTo, sendTo, "", subject, "", htmlString)
|
||||
err := helper.SendEmail(sendTo, sendTo, "", subject, "", htmlString)
|
||||
if err != nil {
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
||||
} else {
|
||||
@@ -112,7 +119,15 @@ func Route(db *gorm.DB) {
|
||||
w.Write([]byte("success"))
|
||||
}))
|
||||
|
||||
http.HandleFunc("/test", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("success"))
|
||||
http.HandleFunc("*", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(404)
|
||||
w.Write([]byte("what are you looking for!?"))
|
||||
}))
|
||||
|
||||
http.Handle("/", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
w.Write([]byte("Welcome!"))
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user