hasmailtemplates

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MailSenderFunc func(string) MailSender = defaultSendGridClient
)

Functions

func InjectVars

func InjectVars(t MailTemplate, vars map[string]string) (string, error)

InjectVars takes a MailTemplate and a key-value map that is used to map template variables in the mail body to resolved values from the input map. This function expects the vars in the template to be formatted as "{var}", where `var` is the key, and it is surrounded by curly braces. This makes it so that the request body can contain a simple key-value pair, e.g.:

{
  "var": "foo"
}

func SendEmail

func SendEmail(ctx context.Context, subject string, to *mail.Email, plainTextContent string, htmlContent string) (*rest.Response, error)

func SendResponse

func SendResponse(w http.ResponseWriter, code int)

SendResponse writes a response back to the HTTP client

Types

type MailRequest

type MailRequest struct {
	Recipient string            `json:"recipient"`
	Name      string            `json:"name,omitempty"`
	Vars      map[string]string `json:"vars"`
}

type MailResponse

type MailResponse struct {
	Success bool `json:"success"`
}

type MailSender

type MailSender interface {
	SendWithContext(ctx context.Context, email *mail.SGMailV3) (*rest.Response, error)
}

type MailTemplate

type MailTemplate interface {
	Body() string
	Name() string
	Subject() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL