api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Package api is Veritix's HTTP interface: the REST and SSE surface the web UI is built on, and the same surface a script or a CI job can drive.

It does not reimplement any part of the audit. Every run goes through audit.Run, and every report served here is the document report.Build produces, so the web interface and the JSON report cannot disagree about what was found.

The contract is internal/api/openapi.yaml, served at /api/v1/openapi.yaml. Settle a change there before changing a handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// Seq numbers the run's progress from 1. The terminal event has no
	// sequence number: it is read from the store rather than replayed from the
	// stream, so it is not at any position in it.
	Seq     int            `json:"seq,omitempty"`
	Type    string         `json:"type"`
	Time    time.Time      `json:"time"`
	Message string         `json:"message,omitempty"`
	Fields  map[string]any `json:"fields,omitempty"`
	// Run is set on the terminal event, so a client that only cares about the
	// outcome can ignore everything before it.
	Run *runJSON `json:"run,omitempty"`
}

Event is one item on a run's stream.

It carries the same class of information as the server's diagnostic log — stages, table names, counts — and no cell values. The one endpoint that serves those is the per-finding rows endpoint, deliberately and alone.

type Options

type Options struct {
	// Store is the run history. Required.
	Store *store.Store
	// Config carries the server and engine settings a run needs.
	Config config.Config
	// Version is reported by /health and recorded on every run.
	Version string
	// Log receives diagnostics. Request logs go here, run progress goes to
	// the run's event stream as well.
	Log *slog.Logger
	// Web is the built web interface, normally web.FS(). It is injected rather
	// than imported so that this package's tests can drive the API without a
	// front-end build, and can serve a stub one when they are testing how it is
	// served. A nil Web serves the JSON 404 that predates the interface.
	Web fs.FS
}

Options configures a server.

type Server

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

Server holds the API's state: the store, the settings a run needs, and the registry of runs currently executing.

func New

func New(ctx context.Context, opts Options) (*Server, error)

New builds a server. The caller owns the store and closes it.

func (*Server) Close

func (s *Server) Close() error

Close ends the event streams and stops any run still executing, waiting for each to unwind so that a shutdown does not leave a DuckDB handle open on a half-written file. It is safe to call more than once.

func (*Server) Handler

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

Handler returns the routed, wrapped HTTP handler.

Jump to

Keyboard shortcuts

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