server

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 25 Imported by: 1 module, 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 server exposes an mqlite Engine as a Connect-style JSON-over-HTTP broker (design §7). Every unary RPC is a plain HTTP POST to /mqlite.v1.<Service>/<Method> with a JSON body — curl-able by construction. A durable broker Engine preserves live tokens under engine.Open's safe default. The higher-level Embedded.Serve path additionally enforces WithBrokerMode so its shutdown and lifecycle contract is selected before serving traffic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateMonitorTokens added in v0.3.2

func ValidateMonitorTokens(admins, monitors []string) error

ValidateMonitorTokens rejects ambiguous or ineffective monitoring credentials. Errors describe configuration only and never contain a credential value.

Types

type Server

type Server struct {
	Version string       // reported by the open "/" discovery endpoint; "" -> "dev"
	CORS    string       // Access-Control-Allow-Origin to send; "" -> CORS off (see cors.go)
	Logger  *slog.Logger // per-request access log; nil -> no request logging (see logging.go)
	UI      bool         // serve the embedded admin console at /ui (see console.go)
	// Metrics enables authenticated GET /metrics on the API listener and includes
	// its path in discovery. Off by default; configure before Handler is used.
	Metrics bool
	// MonitorTokens grants only Observe and /metrics. Configure before Handler is
	// used. These credentials never consult the database and cannot manage keys.
	MonitorTokens []string
	// MaxBodyBytes bounds any single RPC request body BEFORE JSON decoding
	// (review F8): without it a multi-GB body OOMs the broker before the
	// per-message MaxMessageBytes check ever runs. Bodies are base64 (x4/3) and
	// a batched Send carries many messages, so the default (32 MiB) sits far
	// above normal use while keeping one hostile request a fraction of the
	// smallest supported deployment's RAM. Over the cap -> 413 message_too_large.
	MaxBodyBytes int64
	// contains filtered or unexported fields
}

Server adapts an Engine to HTTP with static administrators and managed access keys.

func New

func New(eng *engine.Engine, tokens []string) *Server

New builds a Server. tokens is the set of accepted Bearer tokens; pass nil/empty to disable auth (documented as a localhost/LAN downgrade, §7.5). Open preserves unexpired leases by default; do not pass ReclaimUnexpiredLeases for an Engine that will be used by a network broker.

func (*Server) Handler

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

Handler returns the HTTP handler: CORS (outermost, so preflight bypasses auth) wrapping the optional request log, Bearer-token auth, the RPC-latency observer, and the route mux.

Jump to

Keyboard shortcuts

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