httpapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 16 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; 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, loopback callers only (see docs/storage.md)

Both are mounted at the ROOT, as the released Express server does. GASP peer routes and 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 Deps

type Deps struct {
	Submit  Submitter
	Lookup  Looker
	Topics  []string
	Ready   func() bool
	Metrics *metrics.Metrics
	Log     *slog.Logger
	// Checkpoint writes a store backup named name and returns its directory.
	// Nil leaves POST /admin/checkpoint unserved. The route answers loopback
	// callers only: the backup timer on the host, never a remote client.
	Checkpoint func(ctx context.Context, name string) (string, error)
}

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