server

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package server wires the emulator's HTTP surface: the data planes (/v1/search, /v1/datastore, /v1/channel, /v1/auth, /v1/functions, /v1/blob, /v1/container, /v1/mailbox, /v1/tasks and the public /fn and /blob paths), the control-plane admin API (/admin), MCP, and the embedded admin console — mounted in the same order as the hosted platform (data plane, then admin, then static assets).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Addr    string
	DataDir string // "" => in-memory
	DevOpen bool

	// StaticDir, when set, serves that build output directory as a site — the local stand-in for
	// a deployment on the hosted static service. It gets its OWN LISTENER rather than a path
	// prefix under the API, because a generator emits root-absolute URLs (/assets/app.js) and a
	// site mounted under a prefix has none of them resolve. Hosted, a site has its own hostname;
	// locally the equivalent is its own port.
	StaticDir  string
	StaticAddr string // defaults to the API port + 1
	StaticSPA  *bool  // nil => detected from the directory

	// AllowOrigins are extra browser origins the data plane may be called from, beyond the
	// loopback ones allowed by default. For the case the default does not cover: a phone or a
	// second machine on the LAN pointed at this emulator.
	AllowOrigins []string

	// MailDomain is the domain every mailbox address is on ("" => mail.localhost).
	MailDomain string
	// SMTPAddr, when set, starts an SMTP listener there that delivers into local mailboxes.
	SMTPAddr string
	// SMTPAuthenticated marks mail received over SMTP as coming from an authenticated sender,
	// so a mailbox in `reply` send mode may answer it.
	SMTPAuthenticated bool
}

Options configures the emulator.

type Server

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

Server is the assembled emulator.

func New

func New(opts Options) (*Server, error)

New builds the server and all service handlers.

func (*Server) Close added in v0.2.37

func (s *Server) Close()

Close stops the listeners New opened (deployed sites, the --static site, SMTP). For tests and for a clean restart; ListenAndServe's own server is the caller's to stop.

func (*Server) Deploy added in v0.2.37

func (s *Server) Deploy(ctx context.Context, req manifest.Request) (*manifest.Response, error)

Deploy applies (or, with DryRun, plans) a manifest in process — `altengine dev --deploy`.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root http.Handler (host guard, CSRF-ish origin guard, CORS, per-instance rate limits, request log).

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the HTTP server.

The function scheduler starts HERE rather than in New, so building a server in a test does not spawn a ticker goroutine that outlives the test.

Jump to

Keyboard shortcuts

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