api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package api serves the Keyway HTTP API (PRD §12) and the embedded web dashboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr  string
	Token string // bearer token required by all /v1 endpoints
}

Config configures the API server.

type Server

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

Server is the HTTP transport. It owns only transport concerns (routing, auth, idempotency, the node-local run index) and delegates all business logic to the application layer (app.Deps). Idempotency storage is the coordination seam, so a multi-replica deployment shares replays via Postgres; the in-flight lock is a same-node coalescing concern.

func NewServer

func NewServer(cfg Config, deps app.Deps) *Server

NewServer constructs an API server over the application-layer dependencies, defaulting to an in-memory idempotency store. Use WithIdempotency to supply a shared (Postgres-backed) store for multi-replica deployments.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe starts the HTTP server and shuts down on ctx cancellation.

func (*Server) Routes

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

Routes builds the HTTP handler.

func (*Server) WithIdempotency

func (s *Server) WithIdempotency(store coordination.IdempotencyStore) *Server

WithIdempotency overrides the idempotency store (e.g. the Postgres-backed one from the coordinator) so retried writes replay across replicas. Returns the server for chaining.

Jump to

Keyboard shortcuts

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