api

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package api wires the HTTP surface together: REST endpoints for auth and Docker operations, the WebSocket upgrade, and serving the embedded SPA.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PProfHandler added in v1.4.0

func PProfHandler() http.Handler

PProfHandler returns an http.Handler exposing Go's net/http/pprof endpoints under /debug/pprof.

It carries NO authentication or IP filtering by design: the caller MUST serve it only on a loopback-bound listener (see cmd/dockercmd's pprof server). That is deliberate — gating by client IP on the *main* router would be unsafe, because the app runs behind chi's RealIP middleware, which rewrites r.RemoteAddr from the (spoofable) X-Forwarded-For / X-Real-IP headers. A physically loopback-only listener can't be reached off-box regardless of headers, so it's the correct boundary for endpoints that leak goroutine stacks / heap layout and can stall the process (/profile).

Types

type Server

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

Server bundles all dependencies needed to serve HTTP.

func NewServer

func NewServer(cfg config.Config, st *store.Store, authSvc *auth.Service, mw *auth.Middleware, dm *docker.Manager, hub *ws.Hub, mon *monitor.Monitor, hist history.Store, webFS fs.FS) *Server

NewServer constructs the API server.

func (*Server) Handler

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

Handler builds the root http.Handler with all routes mounted.

func (*Server) OnRestart added in v1.5.0

func (s *Server) OnRestart(fn func())

OnRestart registers the hook that gracefully restarts the process (re-exec of the on-disk binary). main wires this only on platforms/run-modes that support it; without it the in-app restart endpoint returns 501.

func (*Server) StartImageUpdatePollLoop added in v1.7.0

func (s *Server) StartImageUpdatePollLoop(ctx context.Context)

StartImageUpdatePollLoop periodically checks every project's running services for a newer image at the registry (see NEXT.md's "Controlled image updates") and notifies once per newly-observed digest. This is detection + notification only — nothing here applies an update; see internal/docker's AugmentDigestDrift, which this reuses, for the same check already done on demand by the deploy preview. Runs until ctx is cancelled.

func (*Server) StartRetentionLoop added in v1.7.0

func (s *Server) StartRetentionLoop(ctx context.Context)

StartRetentionLoop purges history older than the configured retention once a day (first run shortly after startup, so a restart-heavy install still purges) until ctx is cancelled. What it deleted is logged and stored (see store.RetentionRun) so nobody has to wonder where old alerts went.

func (*Server) StartSelfUpdatePolicyLoop added in v1.7.0

func (s *Server) StartSelfUpdatePolicyLoop(ctx context.Context)

StartSelfUpdatePolicyLoop periodically applies a newer release automatically when an admin has opted into it, following the same cache TTL as the manual update check (there's no point polling for a policy decision more often than the underlying GitHub check itself refreshes). Runs until ctx is cancelled.

Jump to

Keyboard shortcuts

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