control

package
v3.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

func NewController

func NewController() (*Controller, error)

func (*Controller) GenerateConfirmID

func (c *Controller) GenerateConfirmID(req *Request) string

func (*Controller) GenerateId

func (c *Controller) GenerateId(hash string) string

GenerateId generates a Message-ID for this newsletter using the given hash.

func (*Controller) GetHashFromId

func (c *Controller) GetHashFromId(messageID string) (string, error)

GetHashFromId retrieves the hash from the given messageID of the form: `USER-HASH@SERVER`

func (*Controller) Handle

func (c *Controller) Handle(route string, r io.Reader) error

func (*Controller) HashWithSecret

func (c *Controller) HashWithSecret(s string) string

type Request

type Request struct {
	letters.Email
	Log       *slog.Logger
	From      *mail.Address
	MessageID string
}

Request is an email received by the controller.

It is a very basic wrapper around letters.Email that parses some additional header fields that we always want to be valid. It is used to pass the context of a single request to the different routes. Its logger Log can be used for contextualised logging.

func ParseRequest

func ParseRequest(logger *slog.Logger, r io.Reader) (*Request, error)

type SyslogHandler

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

SyslogHandler is a basic shim between slog.Handler and syslog.Writer.

func NewSyslogHandler

func NewSyslogHandler(writer Writer) *SyslogHandler

NewSyslogHandler creates a new SyslogHandler using the given writer.

func (*SyslogHandler) Enabled

func (h *SyslogHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level.

func (*SyslogHandler) Handle

func (h *SyslogHandler) Handle(ctx context.Context, r slog.Record) (err error)

Handle handles the Record.

func (*SyslogHandler) WithAttrs

func (h *SyslogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new Handler whose attributes consist of both the receiver's attributes and the arguments.

func (*SyslogHandler) WithGroup

func (h *SyslogHandler) WithGroup(name string) slog.Handler

WithGroup returns a new Handler with the given group appended to the receiver's existing groups.

type Writer

type Writer interface {
	Info(message string) error
	Warning(message string) error
	Err(message string) error
}

Writer is the minimal interface required by [Logger] for its underlying writer.

Jump to

Keyboard shortcuts

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