removed routers
parent
6cc0005054
commit
9c32e1b9ff
|
@ -1,38 +0,0 @@
|
||||||
package mail
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"git.umbach.dev/app-idea/mailer/modules/mailer"
|
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MailInput struct {
|
|
||||||
Key string `json:"k"`
|
|
||||||
Mail string `json:"m"`
|
|
||||||
TemplateId int `json:"t"`
|
|
||||||
LanguageId int `json:"l"`
|
|
||||||
BodyData *json.RawMessage `json:"d"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func SendMail(c *fiber.Ctx) error {
|
|
||||||
var input MailInput
|
|
||||||
|
|
||||||
if err := c.BodyParser(&input); err != nil {
|
|
||||||
log.Infoln("bodyParser failed:", err)
|
|
||||||
return c.SendStatus(fiber.StatusUnauthorized)
|
|
||||||
}
|
|
||||||
|
|
||||||
var bodyData map[string]interface{}
|
|
||||||
|
|
||||||
if err := json.Unmarshal(*input.BodyData, &bodyData); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infoln("input", input, bodyData)
|
|
||||||
|
|
||||||
mailer.NewMail([]string{"app@roese.dev"}, input.TemplateId, input.LanguageId, bodyData)
|
|
||||||
|
|
||||||
return c.SendStatus(fiber.StatusOK)
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package router
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
|
|
||||||
"git.umbach.dev/app-idea/mailer/routers/api/mail"
|
|
||||||
)
|
|
||||||
|
|
||||||
func SetupRoutes(app *fiber.App) {
|
|
||||||
app.Post("/send", mail.SendMail)
|
|
||||||
}
|
|
Loading…
Reference in New Issue