Documentation
¶
Overview ¶
Package httpapi is the REST API of the admin listener (api/openapi.yaml, PHASE1 step 13): hand-written on net/http and encoding/json. The spec comes first; every route here is an operation of it, and the contract tests check both against each other.
Every request runs through the same chain: request ID and access log, cross-origin protection, the session (or 401), the CSRF token for changes, the JSON body rules – then the handler, which calls the services. The services check the permissions themselves (security.md); the handlers only translate between HTTP and them.
Index ¶
Constants ¶
const BasePath = "/api/v1"
BasePath is where the API lives on the admin listener.
const MaxBody = 128 << 10
MaxBody is the size limit of a request body (CSRs fit easily).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the handler of BasePath.
type Deps ¶
type Deps struct {
Auth *auth.Service
Engine *ca.Engine
Keys *keys.Keyring
Presets *preset.Set
Clock clock.Clock
Log *slog.Logger
// TrustedProxies may set X-Forwarded-For (auth.trusted_proxies).
TrustedProxies []netip.Prefix
Version string
Demo bool
// Settings are the tenant settings (step 18); Tenant is the tenant of
// this API ("" = store.DefaultTenant).
Settings *tenant.Store
Tenant string
// TenantAudit and InstanceAudit are the audit logs for reading (step 18).
TenantAudit, InstanceAudit *sql.DB
// Agents is the agent service (v0.3); nil while agent.base_url is empty.
Agents *agents.Service
// ACME is nil while the ACME server is disabled.
ACME *acme.Server
}
Deps are the services the API calls.