api

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package api implements the v1.3+ REST API. Routes mount under /api/v1. The API is JSON-only, returns a consistent error envelope {"error":"..."} on every non-2xx, supports pagination via ?page + ?per_page query params, and emits ETag headers for cacheable read endpoints so well-behaved clients (and the v1.4 studio UI) skip re-rendering identical responses.

Auth: every route is gated on either a session cookie (browser flows) or a Bearer token with the right scope (machine flows). The Mount() function wires both middlewares; downstream handlers resolve the actor via auth.TokenFromContext + auth.FromContext.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is the surface the daemon mounts onto its chi router. Holds references to the persistence + auth dependencies the handlers need.

func New

func New(st *store.Store, users *auth.Users, tokens *auth.Tokens, sessions *auth.Sessions) *API

New constructs the API handle. The Mount() method wires every route on r under the /api/v1 prefix.

func (*API) Mount

func (a *API) Mount(r chi.Router)

Mount installs the v1 routes on r. Phase 6 ships the read surface; phase 7 layers the write endpoints on this same prefix. Phase 11 (UI shell) calls Mount before starting the server.

func (*API) WithEvents added in v1.6.0

func (a *API) WithEvents(p *events.Producer) *API

WithEvents installs the v1.6 SSE Producer. Returns the receiver for chaining. When set, the /api/v1/events route is mounted; otherwise it 404s and the daemon's polling paths still work.

Jump to

Keyboard shortcuts

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