relay

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
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

func SetupRouter(h *Handler) *mux.Router

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

func ValidateAgainstDescriptorSchema(bb []byte) error

ValidateAgainstDescriptorSchema validates a message coming from the client against Descriptor schema.

func ValidateAgainstMessageSchema

func ValidateAgainstMessageSchema(bb []byte) error

ValidateAgainstMessageSchema validates a message coming from the client against Message schema.

func ValidateAgainstTokenSchema

func ValidateAgainstTokenSchema(bb []byte) error

ValidateAgainstTokenSchema validates a message coming from the client against Token schema.

Types

type Descriptor

type Descriptor string

Descriptor identifies a channel.

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

type MailgunData struct {
	APIKey  string
	Address string
}

MailgunData holds the API key and the server address of MailGun.

type MailgunResponse

type MailgunResponse struct {
	Human string
	MsgID string
}

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.

type Token

type Token string

Token is a string authenticating the sender of an HTTP request.

Jump to

Keyboard shortcuts

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