Documentation ¶
Index ¶
- Constants
- func PutMessage(h *Handler, w http.ResponseWriter, r *http.Request)
- func SetupRouter(h *Handler) *mux.Router
- func ValidateAgainstDescriptorSchema(bb []byte) error
- func ValidateAgainstMessageSchema(bb []byte) error
- func ValidateAgainstTokenSchema(bb []byte) error
- type Descriptor
- type Handler
- type MailgunData
- type MailgunResponse
- type Message
- type Token
Constants ¶
const DefaultMailgunAddress = mailgun.ApiBase
DefaultMailgunAddress is the URL of the MailGun v3 API.
Variables ¶
This section is empty.
Functions ¶
func PutMessage ¶
func PutMessage(h *Handler, w http.ResponseWriter, r *http.Request)
PutMessage sends a message to the server, which relays it to the MailGun API.
The given (descriptor, token) pair are authenticated first. The message's metadata is determined by the channel information from the database.
func SetupRouter ¶
SetupRouter sets up a router. If you don't use any middleware, you are good to go. Otherwise, you need to maually re-implement this function with your middlewares.
func ValidateAgainstDescriptorSchema ¶
ValidateAgainstDescriptorSchema validates a message coming from the client against Descriptor schema.
func ValidateAgainstMessageSchema ¶
ValidateAgainstMessageSchema validates a message coming from the client against Message schema.
func ValidateAgainstTokenSchema ¶
ValidateAgainstTokenSchema validates a message coming from the client against Token schema.
Types ¶
type Handler ¶
type Handler struct { LogErr *log.Logger LogOut *log.Logger MailgunData MailgunData Env *database.Env }
Handler holds the global dependencies for handling the routes.
type MailgunData ¶
MailgunData holds the API key and the server address of MailGun.
type MailgunResponse ¶
MailgunResponse the response of the MailGun API call.
type Message ¶
type Message struct { // contains the text to be used as the email's subject. Subject string `json:"subject"` // contains the text to be used as the email's content. Content string `json:"content"` // contains the optional html text to be used as the email's content. // // If set, the "content" field of the Message is ignored. HTML *string `json:"html,omitempty"` }
Message represents a message to be relayed.