less-bloat-2

This commit is contained in:
Untone 2024-01-05 13:19:46 +03:00
parent c5aaad0662
commit 896e890421

View File

@ -14,14 +14,13 @@ import (
const apiURL = "https://api.mailgun.net/v3/%s/messages" const apiURL = "https://api.mailgun.net/v3/%s/messages"
func mailgun_send(to []string, data map[string]interface{}, subject string, template string) error { func mailgun_send(to string, data map[string]interface{}, subject string, template string) error {
var mailgunAPIKey = os.Getenv("MAILGUN_API_KEY") var mailgunAPIKey = os.Getenv("MAILGUN_API_KEY")
var mailgunDomain = os.Getenv("MAILGUN_DOMAIN") var mailgunDomain = os.Getenv("MAILGUN_DOMAIN")
// Create custom variables JSON vars, err := json.Marshal(data)
customVariablesJSON, err := json.Marshal(data)
if err != nil { if err != nil {
return err vars = nil
} }
// Create payload // Create payload
@ -30,7 +29,7 @@ func mailgun_send(to []string, data map[string]interface{}, subject string, temp
"to": to, "to": to,
"subject": subject, "subject": subject,
"template": template, "template": template,
"h:X-Mailgun-Variables": string(customVariablesJSON), "h:X-Mailgun-Variables": string(vars),
} }
// Convert payload to JSON // Convert payload to JSON