server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 17 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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)
	// 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 Bearer-token auth.

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).

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