Help us shape the future of Go! Take the 2026 Go Developer Survey

server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *config.Config, db *sql.DB, client *ent.Client, site apisite.Deps, external, mcp, staff http.Handler) (http.Handler, error)

New builds the top-level net/http handler wiring the three ogen-generated API servers (site, external, collect) and the public endpoints. New composes the HTTP handler. client is the raw ent client: only the pieces whose Workspace is not known up front take it (auth, OAuth, tracking, provider hooks); the site, external and collect handlers get none (ADR 0017).

func NewExternalAPI

func NewExternalAPI(client *ent.Client, deps apiexternal.Deps) (http.Handler, error)

NewExternalAPI builds the external API (/api) ogen server: Bearer API-token auth, RFC 7807 errors, mounted under the /api prefix.

func NewInternal

func NewInternal(cfg *config.Config, client *ent.Client, surface ServiceSurface) (http.Handler, error)

NewInternal builds the handler of the internal listener (ADR 0026): the service endpoints under /service and nothing else, behind the middleware the public server uses where it applies (recoverer, request id, client address, rate limit, timeout, body limit). The edge's on-demand TLS question (paths.TLSAsk, ADR 0038) is core and always served; the service endpoints exist only with a surface, so a nil one (no `staff` license) leaves /service unrouted (404).

func NewStaffAPI

func NewStaffAPI(surface StaffSurface) (http.Handler, error)

NewStaffAPI builds the /staff ogen server with RFC 7807 errors. A nil surface (no `staff` license) yields a nil handler, which New mounts as a 404.

func SchemaGuard

func SchemaGuard(watch PendingMigrations) func(http.Handler) http.Handler

SchemaGuard answers 503 with a problem that names the migrate command while the database lacks migrations this binary needs, instead of letting every query fail with a bare 500. The probe paths pass: /healthz is liveness only, and /readyz reports on the database itself. A failed lookup lets the request through: an unreachable database fails it on its own.

Types

type PendingMigrations

type PendingMigrations interface {
	Pending(ctx context.Context) (int, error)
}

PendingMigrations is what SchemaGuard asks: how many migrations the database has not run.

type ServiceSurface

type ServiceSurface interface {
	Server(opts ...serviceapi.ServerOption) (http.Handler, error)
}

ServiceSurface is the service endpoints of the Staff surface (ee/staff), built into an ogen server here so it renders errors like the other surfaces.

type StaffSurface

type StaffSurface interface {
	Server(opts ...staffapi.ServerOption) (http.Handler, error)
}

StaffSurface is the Enterprise Staff member API (ee/staff), built into an ogen server here so it renders errors like the other surfaces.

Jump to

Keyboard shortcuts

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