Documentation
¶
Overview ¶
Package httpserver builds the HTTP transport every service in this repo runs on: CORS, access logging with correlation IDs, and the Serve/Shutdown lifecycle pkg/boot.Service expects. A service package supplies only its own routes and gets the rest for free instead of rebuilding http.Server and its middleware chain by hand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Name string
Component string
Address string
CORS config.CORSConfig
Timeouts config.HTTPDefaults
Registration
}
Config is what pkg/boot.Boot builds from a Registration plus what only the platform layer decides: name, listen address, and the CORS/timeout defaults every HTTP server in this repo shares.
type Registration ¶
type Registration struct {
// ServiceTokenHeader, if set, is added to CORS's allowed headers so a
// browser-based service-to-service caller can present it; leave empty
// if the service takes no service-token header.
ServiceTokenHeader string
// SetupRoutes registers the service's own handlers on mux. Required.
SetupRoutes func(mux *http.ServeMux)
// Closers are closed, in order, after the HTTP server has shut down.
Closers []io.Closer
}
Registration is what a service provides: its routes, never the transport around them.
Click to show internal directories.
Click to hide internal directories.