server

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 20 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 server wires the sprite store behind a net/http router that speaks the Sprites REST surface over the /v1 path space. It uses Go 1.22+ method+pattern routing so it needs no third-party router, and is wire-compatible with chant's in-process Sprites fake.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error  string `json:"error"`
	Status int    `json:"status,omitempty"`
}

ErrorResponse is the JSON body spritzer returns for any non-2xx status. It carries an "error" message and a machine-readable status.

type Options

type Options struct {
	Version string
	Clock   clock.Clock
	Logger  *slog.Logger
	// Runtime, when set, is container exec mode: sprites are containers and
	// exec runs real commands (see real.go). Nil is the scripted interpreter.
	Runtime runtime.Backend
	// URLDomain, in container mode, also serves each sprite's URL at
	// <name>.<URLDomain> (for example "localhost", giving
	// http://box.localhost:4290). The path form /s/<name> always works.
	URLDomain string
}

Options configures a Server.

type Server

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

Server holds the spritzer state and serves the API.

func New

func New(opts Options) *Server

New constructs a Server, filling in sensible defaults for any zero option.

func (*Server) Adopt added in v0.6.0

func (s *Server) Adopt(ctx context.Context) error

Adopt records every sprite container the runtime already holds, so a restarted spritzer (a new pod, say) still knows the sprites it made.

func (*Server) Handler

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

Handler returns the HTTP handler for the server.

Jump to

Keyboard shortcuts

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