handler

package
v0.0.0-...-25a6cea Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package handler implements AWS Lambda event handling.

Index

Constants

View Source
const (
	Undefined eventOperationType = iota
	Subscribe
	Verify
	Unsubscribe
)
View Source
const ErrUserInput = types.SentinelError("invalid user input")

Inspired by the example from the "Customizing error tests with Is and As methods" section of https://go.dev/blog/go1.13-errors.

View Source
const ResponseTemplate = `` /* 259-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType

type EventType int
const (
	UnknownEvent EventType = iota
	ApiRequest
	MailtoEvent
	SnsEvent
	CommandLineEvent
)

func (EventType) String

func (i EventType) String() string

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(
	emailDomain string,
	siteTitle string,
	agent agent.SubscriptionAgent,
	paths RedirectPaths,
	responseTemplate string,
	unsubscribeUserName string,
	bouncer email.Bouncer,
	logger *log.Logger,
) (*Handler, error)

func (*Handler) HandleEvent

func (h *Handler) HandleEvent(
	ctx context.Context, event *Event,
) (result any, err error)

type Options

type Options struct {
	ApiDomainName        string
	ApiMappingKey        string
	EmailDomainName      string
	EmailSiteTitle       string
	SenderName           string
	SenderUserName       string
	UnsubscribeUserName  string
	UnsubscribeFormPath  string
	SubscribersTableName string
	ConfigurationSet     string
	MaxBulkSendCapacity  types.Capacity

	RedirectPaths RedirectPaths
}

func GetOptions

func GetOptions(getenv func(string) string) (*Options, error)

type ParseError

type ParseError struct {
	Type    eventOperationType
	Message string
}

func (*ParseError) Error

func (e *ParseError) Error() string

type RedirectMap

type RedirectMap map[ops.OperationResult]string

type RedirectPaths

type RedirectPaths struct {
	Invalid           string
	AlreadySubscribed string
	VerifyLinkSent    string
	Subscribed        string
	NotSubscribed     string
	Unsubscribed      string
}

type UndefinedEnvVarsError

type UndefinedEnvVarsError struct {
	UndefinedVars []string
}

func (*UndefinedEnvVarsError) Error

func (e *UndefinedEnvVarsError) Error() string

Jump to

Keyboard shortcuts

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