Documentation
¶
Overview ¶
Package server assembles the HTTP layer: it collects every module's route contributions, builds the chi router and the OpenAPI document, and serves the non-domain endpoints (probes, websocket).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Package = do.Package( do.Lazy(NewMiddlewares), do.Lazy(NewHealthService), do.Lazy(NewRouter), do.Lazy(NewHttp), do.LazyNamed(registry.RoutePrefix+"health", HealthRoutes), do.LazyNamed(registry.RoutePrefix+"ws", WsRoutes), )
Package wires the HTTP server: the router, the http.Server around it, the middleware, the probes and the websocket endpoint.
Functions ¶
Types ¶
type Endpoint ¶
type Endpoint struct {
Method string
Path string
Handler http.HandlerFunc
Summary string
Tags []string
// Request documents parameters and body: uri tags become path
// parameters, query tags query parameters, json tags the body —
// constraints are read from the validate tags.
Request any
// Response documents the response body; Status defaults to 200.
Response any
Status int
}
Endpoint declares one HTTP endpoint: how to serve it and, through the Request/Response samples, how to document it. Endpoints without either stay out of the OpenAPI document (probes, websockets).
type Endpoints ¶
type Endpoints []Endpoint
Endpoints is a module's contribution to the HTTP router.
func HealthRoutes ¶
HealthRoutes endpoints are undocumented, so they carry no Request/Response samples.
type HealthService ¶
type HealthService struct {
// contains filtered or unexported fields
}
HealthService serves the container/orchestrator probes.
func NewHealthService ¶
func NewHealthService(i do.Injector) (*HealthService, error)
func (*HealthService) Healthz ¶
func (r *HealthService) Healthz(w http.ResponseWriter, req *http.Request)
Healthz is the liveness probe: the process is up and serving.
func (*HealthService) Readyz ¶
func (r *HealthService) Readyz(w http.ResponseWriter, req *http.Request)
Readyz is the readiness probe: every health-checkable service in the container (the database, and whatever you add later) must pass.
type Middlewares ¶
type Middlewares struct {
// contains filtered or unexported fields
}
func NewMiddlewares ¶
func NewMiddlewares(i do.Injector) (*Middlewares, error)