api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api implements the imsgd HTTP API described by api/openapi.yaml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	DB           *db.DB
	APIKeys      []config.APIKey
	Version      string
	MacOSVersion string
	// Names resolves contact names; nil disables resolution.
	Names present.NameResolver
	// AttachmentRoots are directories attachment content may be served from.
	// Defaults to ~/Library/Messages/Attachments and StickerCache (never the
	// database files beside them).
	AttachmentRoots []string
	// Bus enables GET /api/v1/events; Store and Webhooks enable the webhook API.
	Bus      *events.Bus
	Store    *store.Store
	Webhooks WebhookDispatcher
	// Sender enables POST /api/v1/messages and GET /api/v1/sends/{id}.
	Sender *send.Sender
	// UploadMaxBytes limits a send request body (default 100 MiB).
	UploadMaxBytes int64
	// Converter enables format=jpeg/m4a on attachment content.
	Converter *media.Converter
	// Dims enables real image dimensions in attachment objects.
	Dims *media.DimensionCache
	// CORSOrigins lists browser origins allowed to call the API ("*" = any).
	CORSOrigins []string
	// SendsPerMinute limits POST /api/v1/messages per API key (default 60,
	// burst 20). StreamsPerKey caps concurrent WebSockets per key (default 20).
	SendsPerMinute int
	StreamsPerKey  int
}

Options configures a Server.

type Server

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

func New

func New(o Options) *Server

func (*Server) HasKey

func (s *Server) HasKey(name string) bool

HasKey reports whether an API key name is currently configured.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetAPIKeys

func (s *Server) SetAPIKeys(keys []config.APIKey)

SetAPIKeys replaces the accepted API keys without a restart.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown closes long-lived connections (WebSockets), which http.Server.Shutdown does not track once upgraded.

type WebhookDispatcher

type WebhookDispatcher interface {
	Invalidate()
	SendTest(ctx context.Context, w *store.Webhook) webhook.TestResult
}

WebhookDispatcher is the subset of *webhook.Dispatcher the API uses.

Jump to

Keyboard shortcuts

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