localserver

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package localserver is the HTTP side of the local OVDB server: the hardening middleware chain, the local API (/api/local/v1/…), the landing page, and the openvaultdb-go data API (/v1/…) mounted behind them. It exists only in local mode; legacy `ovdb serve` never uses it (REQ:local-mode-only-for-new-surfaces).

Increment 1a serves an empty database map; the registry, console, login and sessions arrive in later increments and slot into the same chain.

Index

Constants

View Source
const AuthStoreFile = "auth.json"

AuthStoreFile holds scoped tokens, hashed, in OVDB home.

View Source
const LocalAPIPrefix = "/api/local/v1/"

LocalAPIPrefix is the versioned local API root.

View Source
const LoginLinkTTL = 10 * time.Minute

LoginLinkTTL is how long a login code stays valid (REQ:login-links).

Variables

This section is empty.

Functions

func Endpoints

func Endpoints() []string

Endpoints lists the local API as "METHOD path".

func New

func New(opts Options) (http.Handler, error)

New builds the local-mode handler with its full middleware chain.

func Run

func Run(ctx context.Context, opts RunOptions) error

Run is the local server process: it takes the home lock, binds loopback, publishes server.json once it serves, and runs until ctx is cancelled or an authenticated shutdown arrives. It removes its runtime files on exit.

Types

type LoginLink struct {
	Schema      int       `json:"schema"`
	URL         string    `json:"url"`
	FallbackURL string    `json:"fallback_url"`
	ExpiresAt   time.Time `json:"expires_at"`
}

LoginLink is the body of POST /api/local/v1/login-links.

type LoginLinkRequest

type LoginLinkRequest struct {
	Next string `json:"next,omitempty"`
}

LoginLinkRequest is its optional request body.

type Options

type Options struct {
	Dirs   paths.Dirs
	Record runtime.Record // this run's server.json content
	Secret string
	// RequestShutdown is called once the shutdown response is written.
	RequestShutdown func()
	Now             func() time.Time // time.Now when nil
	// ErrorLog receives recovered panics; they are redacted before writing.
	ErrorLog io.Writer
}

Options configure one local server.

type RunOptions

type RunOptions struct {
	Dirs    paths.Dirs
	Port    int
	Version string
	Listen  runtime.ListenFunc // net.Listen when nil
	Log     io.Writer          // server.log in a detached server
	// FailBeforeReady makes the process exit after taking the lock and
	// before it is ready; tests use it to prove server_start_failed.
	FailBeforeReady bool
}

RunOptions configure the server process.

Jump to

Keyboard shortcuts

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