httpapi

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 19 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 httpapi is the host's HTTP surface, path for path and shape for shape with the TypeScript host it replaces (overlay-blueprints src/http.ts):

POST /submit   BRC-22: body = BEEF bytes, header x-topics (and the bridge's
               SPV marker, internal/bridgetrust); answers the BARE STEAK map
POST /lookup   BRC-24: {service, query}; answers {type, outputs:[{beef:[bytes], outputIndex}]}
GET  /healthz  liveness
GET  /readyz   storage and the chain tracker both answer
GET  /metrics  Prometheus

POST /admin/checkpoint  store backup: the index, the modules' state, the blobs
POST /admin/gc          store gc (blobs and metas no row refers to)
POST /admin/prune       the anytx retention, now
GET  /admin/stats       the store's counts
               (the /admin routes answer loopback callers only; docs/storage.md)

POST /requestSyncResponse, POST /requestForeignGASPNode
               the GASP peer routes (internal/catchup), to the configured peers

All are mounted at the ROOT, as the released Express server does. The TypeScript host's other /admin routes are not served.

Index

Constants

View Source
const (
	MaxBody     = 64 << 20
	MaxQuestion = 64 << 10
)

MaxBody matches the bridge's object ceiling; MaxQuestion is generous for a BRC-24 question and three orders of magnitude below it.

Variables

This section is empty.

Functions

func Handler

func Handler(d Deps) http.Handler

Handler builds the mux.

func ParseTopics

func ParseTopics(values []string) ([]string, error)

ParseTopics reads x-topics in both wire forms: a JSON array (the SDK's facilitator) or a comma list (the generated server's binder). Values are trimmed; a repeated header, an empty entry or no topic at all is an error rather than a silently shorter list. (Upstream's Go server comma-splits UNTRIMMED and reads only the first value; this host does not inherit that.)

Types

type BridgeVerifiedSubmitter added in v0.10.0

type BridgeVerifiedSubmitter interface {
	SubmitBridgeVerified(ctx context.Context, raw []byte, topics []string) (overlay.Steak, error)
}

BridgeVerifiedSubmitter is a Submitter that can take an object whose overlay-bridge marker was accepted, verifying everything but its scripts (the pipeline's SubmitBridgeVerified). A Submitter without it verifies every object in full.

type Deps

type Deps struct {
	Submit  Submitter
	Lookup  Looker
	Topics  []string
	Ready   func() bool
	Metrics *metrics.Metrics
	Log     *slog.Logger
	// Checkpoint writes a checkpoint named name (with the blob snapshot when
	// blobs) and answers what it wrote, its directory as "dir". Nil leaves
	// POST /admin/checkpoint unserved. The /admin routes answer loopback
	// callers only: the backup timer and the operator on the host, never a
	// remote client.
	Checkpoint func(ctx context.Context, name string, blobs bool) (any, error)
	// GC runs store gc; ok false is a maintenance pass running (409). Nil
	// leaves POST /admin/gc unserved.
	GC func(ctx context.Context, dryRun, rowless bool) (res any, ok bool, err error)
	// Prune runs the anytx retention now, keeping keep when it is above
	// zero instead of the configured hours; ok false as GC's. Nil leaves
	// POST /admin/prune unserved.
	Prune func(ctx context.Context, dryRun bool, keep time.Duration) (res any, ok bool, err error)
	// Stats counts the store (files: the blob files too). Nil leaves GET
	// /admin/stats unserved.
	Stats func(ctx context.Context, files bool) (any, error)
	// GASP mounts the GASP peer routes (internal/catchup Server); nil leaves
	// them unserved.
	GASP interface{ Register(mux *http.ServeMux) }
	// Trust judges overlay-bridge's SPV marker on POST /submit; nil is
	// trust off (a marker counts as disabled and the object is verified in
	// full).
	Trust *bridgetrust.Trust
}

Deps is what the server needs.

type Looker

type Looker interface {
	Lookup(ctx context.Context, q *lookup.LookupQuestion) (*lookup.LookupAnswer, error)
}

Looker is the engine's lookup.

type Submitter

type Submitter interface {
	Submit(ctx context.Context, raw []byte, topics []string) (overlay.Steak, error)
}

Submitter is the pipeline, as the server sees it.

Jump to

Keyboard shortcuts

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