web

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package web is the ant web console: a browser GUI over the whole resource-URI namespace, server-rendered in pure Go and styled to match shadcn/ui, with the machine-facing JSON API preserved under content negotiation. It is the human surface that sits beside the CLI and the MCP server (8000_ant_serve).

The console adds no data capability of its own; every page is a thin rendering of an ant.Engine method. It depends only on the Deref interface, so it is testable against a fake and could later be mounted by another host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build struct {
	Version string
	Commit  string
	Date    string
}

Build is the binary's release identity, surfaced on the About page and used to cache-bust the embedded assets.

type Console

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

Console renders the web surface over a Deref.

func New

func New(e Deref, b Build) (*Console, error)

New parses every template against the embedded FS and returns a ready Console. Parsing once at construction means no per-request template work.

func (*Console) Handler

func (c *Console) Handler() http.Handler

Handler returns the console's HTTP handler. It routes by the first path segment rather than through http.ServeMux on purpose: a resource URI in the path carries a "//" (GET /x://status/20) and ServeMux's path cleaning would 301-redirect it before any handler ran. Dispatching on the first segment leaves the raw path untouched (the regression serve_test.go guards).

type Deref

type Deref interface {
	Domains() []ant.DomainInfo
	Domain(scheme string) (ant.DomainInfo, bool)
	Resolve(input, on string) (kit.URI, error)
	URL(u kit.URI) (string, error)
	Get(ctx context.Context, u kit.URI) (kit.Envelope, error)
	Dereference(ctx context.Context, u kit.URI, refresh bool) (ant.Fetched, error)
	Lookup(u kit.URI) (ant.Fetched, bool)
	Cached(u kit.URI) bool
	BodyOf(env kit.Envelope) (string, bool)
	List(ctx context.Context, u kit.URI, n int) ([]kit.Envelope, error)
	Searchable(scheme string) bool
	Search(ctx context.Context, scheme, query string, n int) ([]kit.Envelope, error)
	Links(ctx context.Context, u kit.URI) ([]kit.URI, error)
	Walk(ctx context.Context, u kit.URI, depth int) (*ant.Graph, error)
	Export(ctx context.Context, u kit.URI, follow int, md bool) (*ant.ExportReport, error)
	LL(prefix string) ([]string, error)
	Root() string
}

Deref is the slice of *ant.Engine the console renders. Keeping it an interface makes the coupling explicit and lets the route tests run against a fake with no network (8000_ant_serve §6.2, §17).

type View

type View struct {
	Title   string
	Active  string // the nav key to mark current
	Nonce   string
	AssetV  string
	Version string
	Domains []domainNav
	Page    any
}

View is the data every page renders against: the shell needs the sidebar domains, the CSP nonce, the asset version, and the build; the page reads Page.

Jump to

Keyboard shortcuts

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