server

package
v0.0.0-...-e816526 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSMTPAddr = "127.0.0.1:1025"
	DefaultHookAddr = "127.0.0.1:7790"
	DefaultAPIAddr  = "127.0.0.1:8091"
	DefaultCap      = 500
)

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, cfg Config) error

Run starts the SMTP receiver, webhook receiver, and Query API in parallel and blocks until ctx is cancelled or one of them errors out.

Types

type Config

type Config struct {
	SMTPAddr string
	HookAddr string
	APIAddr  string
	Cap      int
}

Config holds runtime addresses and buffer capacity for Run.

type Event

type Event struct {
	Kind string          `json:"kind"` // "mail" | "hook"
	Data json.RawMessage `json:"data"`
}

Event is the wire format used by /tail and the in-process pub/sub bus.

type Hook

type Hook struct {
	ID      string              `json:"id"`
	Time    time.Time           `json:"time"`
	Method  string              `json:"method"`
	Path    string              `json:"path"`
	Query   string              `json:"query"`
	Headers map[string][]string `json:"headers"`
	Body    string              `json:"body"`
	Remote  string              `json:"remote"`
}

Hook is a captured HTTP request.

type Mail

type Mail struct {
	ID      string            `json:"id"`
	Time    time.Time         `json:"time"`
	From    string            `json:"from"`
	To      []string          `json:"to"`
	Subject string            `json:"subject"`
	Headers map[string]string `json:"headers"`
	Body    string            `json:"body"`           // preferred display body (text if present, else html)
	Text    string            `json:"text,omitempty"` // text/plain part (decoded)
	HTML    string            `json:"html,omitempty"` // text/html part (decoded)
	Raw     string            `json:"raw"`
}

Mail is a captured SMTP message after MIME parsing.

type Rule

type Rule struct {
	ID      string            `json:"id"`
	Created time.Time         `json:"created"`
	Method  string            `json:"method"`
	Path    string            `json:"path"`
	Status  int               `json:"status"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    string            `json:"body,omitempty"`
	DelayMs int               `json:"delay_ms,omitempty"`
}

Rule is a Beeceptor-style mock response. Incoming hook requests matching Method+Path get this response instead of the default. Captures still happen.

  • Method "" or "*" matches any method (case-insensitive otherwise).
  • Path "" or "*" matches any path. Trailing "/*" matches any subpath.
  • Newest-added rule wins on tie.