server

package
v0.0.0-...-6ef181b Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 18 Imported by: 0

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

Package wires the HTTP server: the router, the http.Server around it, the middleware, the probes and the websocket endpoint.

Functions

func HTTP

func HTTP(i do.Injector, r chi.Router) error

HTTP registers every "routes:*" contribution on r.

func NewHttp

func NewHttp(i do.Injector) (*http.Server, error)

func NewRouter

func NewRouter(i do.Injector) (*chi.Mux, error)

func SpecJSON

func SpecJSON(i do.Injector, title string) ([]byte, error)

SpecJSON assembles the OpenAPI 3.1 document from every documented endpoint. chi path params already use the {name} form OpenAPI expects.

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

func HealthRoutes(i do.Injector) (Endpoints, error)

HealthRoutes endpoints are undocumented, so they carry no Request/Response samples.

func WsRoutes

func WsRoutes(i do.Injector) (Endpoints, error)

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)

func (*Middlewares) Globals

func (r *Middlewares) Globals(mux *chi.Mux) []func(http.Handler) http.Handler

Jump to

Keyboard shortcuts

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