Documentation
¶
Overview ¶
Package http provides an HTTP transport for the controls lifecycle controller, exposing health, readiness, and management endpoints for use with container orchestrators and load balancers.
Index ¶
- func HealthHandler(controller controls.Controllable) http.HandlerFunc
- func LivenessHandler(controller controls.Controllable) http.HandlerFunc
- func NewClient(opts ...ClientOption) *http.Client
- func NewServer(ctx context.Context, cfg config.Containable, handler http.Handler) (*http.Server, error)
- func NewTransport(tlsCfg *tls.Config) *http.Transport
- func ReadinessHandler(controller controls.Controllable) http.HandlerFunc
- func Register(ctx context.Context, id string, controller controls.Controllable, ...) (*http.Server, error)
- func Start(cfg config.Containable, logger logger.Logger, srv *http.Server) controls.StartFunc
- func Status(srv *http.Server) controls.StatusFunc
- func Stop(logger logger.Logger, srv *http.Server) controls.StopFunc
- type ClientOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HealthHandler ¶
func HealthHandler(controller controls.Controllable) http.HandlerFunc
HealthHandler returns an http.HandlerFunc that responds with the controller's health report.
func LivenessHandler ¶
func LivenessHandler(controller controls.Controllable) http.HandlerFunc
LivenessHandler returns an http.HandlerFunc that responds with the controller's liveness report.
func NewClient ¶
func NewClient(opts ...ClientOption) *http.Client
NewClient returns an *http.Client with security-focused defaults: TLS 1.2 minimum, curated cipher suites, timeouts, connection limits, and redirect policy that rejects HTTPS-to-HTTP downgrades.
func NewServer ¶
func NewServer(ctx context.Context, cfg config.Containable, handler http.Handler) (*http.Server, error)
NewServer returns a new preconfigured http.Server.
func NewTransport ¶
NewTransport returns a preconfigured *http.Transport with security-focused defaults: curated TLS configuration, connection limits, and timeouts. If tlsCfg is nil, defaultTLSConfig() is used.
func ReadinessHandler ¶
func ReadinessHandler(controller controls.Controllable) http.HandlerFunc
ReadinessHandler returns an http.HandlerFunc that responds with the controller's readiness report.
func Register ¶
func Register(ctx context.Context, id string, controller controls.Controllable, cfg config.Containable, logger logger.Logger, handler http.Handler) (*http.Server, error)
Register creates a new HTTP server and registers it with the controller under the given id.
Types ¶
type ClientOption ¶
type ClientOption func(*clientConfig)
ClientOption configures the secure HTTP client.
func WithMaxRedirects ¶
func WithMaxRedirects(n int) ClientOption
WithMaxRedirects sets the maximum number of redirects to follow. Default: 10. Set to 0 to disable redirect following entirely.
func WithTLSConfig ¶
func WithTLSConfig(cfg *tls.Config) ClientOption
WithTLSConfig overrides the default TLS configuration. The caller is responsible for ensuring the provided config meets security requirements.
func WithTimeout ¶
func WithTimeout(d time.Duration) ClientOption
WithTimeout sets the overall request timeout. Default: 30s.
func WithTransport ¶
func WithTransport(rt http.RoundTripper) ClientOption
WithTransport overrides the entire HTTP transport. When set, transport-level options (TLS config, connection limits) are ignored.