Documentation
¶
Overview ¶
Package server composes the HTTP handler: the ogen servers of every surface, the public endpoints (tracking links, hooks, health), the SPA and the middleware around them.
Index ¶
- func New(cfg *config.Config, db *sql.DB, client *ent.Client, site apisite.Deps, ...) (http.Handler, error)
- func NewExternalAPI(client *ent.Client, deps apiexternal.Deps) (http.Handler, error)
- func NewInternal(cfg *config.Config, client *ent.Client, surface ServiceSurface) (http.Handler, error)
- func NewStaffAPI(surface StaffSurface) (http.Handler, error)
- func SchemaGuard(watch PendingMigrations) func(http.Handler) http.Handler
- type PendingMigrations
- type ServiceSurface
- type StaffSurface
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, detector *machine.Detector, 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 ¶
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 ¶
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.