httphandler

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleAdmissionWebhook

func HandleAdmissionWebhook(webhook controllermanager.Webhook) http.HandlerFunc

HandleAdmissionWebhook returns a http.HandlerFunc for a Webhook.

func ListenAndServeHTTP added in v0.3.0

func ListenAndServeHTTP(
	ctx context.Context,
	config *configv1alpha1.HTTPSpec,
	healthHandler HealthHandler,
	bootstrapConfig runtime.Object,
	configsGetter controllercontext.Configs,
) error

ListenAndServeHTTP listens on the given TCP address and gracefully stops when the given context is canceled, setting up all HTTP handlers.

func ListenAndServeWebhooks

func ListenAndServeWebhooks(
	ctx context.Context,
	config *configv1alpha1.WebhookServerSpec,
	webhooks []controllermanager.Webhook,
) error

ListenAndServeWebhooks listens on the given TCP address and gracefully stops when the given context is canceled, setting up all webhooks handlers.

func ServeDebug added in v0.3.0

func ServeDebug(mux *http.ServeMux, cfg *configv1alpha1.HTTPDebugSpec, handler DebugHandler)

ServeDebug adds debug handlers to the given serve mux.

func ServeHealth

func ServeHealth(mux *http.ServeMux, cfg *configv1alpha1.HTTPHealthSpec, handler HealthHandler)

ServeHealth adds health probe handlers to the given serve mux.

func ServeMetrics

func ServeMetrics(mux *http.ServeMux, cfg *configv1alpha1.HTTPMetricsSpec, registry prometheus.Gatherer)

ServeMetrics adds Prometheus metrics handlers to the given serve mux.

func ServePprof added in v0.3.0

func ServePprof(mux *http.ServeMux, cfg *configv1alpha1.HTTPPprofSpec)

ServePprof adds the pprof debug handler to the given serve mux.

func ServeWebhooks

func ServeWebhooks(mux *http.ServeMux, webhooks []controllermanager.Webhook)

ServeWebhooks prepares admission webhooks to be served. TODO(irvinlim): Handle conversion webhooks here in the future too.

Types

type DebugHandler added in v0.3.0

type DebugHandler interface {
	GetBootstrapConfig() runtime.Object
	GetDynamicConfig() (map[configv1alpha1.ConfigName]runtime.Object, error)
}

DebugHandler is a delegate to fetch debug information.

type HealthHandler added in v0.3.0

type HealthHandler interface {
	GetReadiness() error
	GetHealth() []controllermanager.HealthStatus
}

HealthHandler is a delegate to get health information.

type ListeningServer added in v0.3.0

type ListeningServer interface {
	ListenAndServe() error
	Shutdown(context.Context) error
}

ListeningServer is implemented by both http.Server (HTTP) and tlsServer (HTTPS).

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a thin wrapper around HTTP servers.

func NewServer added in v0.3.0

func NewServer(addr string) *Server

func (*Server) Handle added in v0.3.0

func (s *Server) Handle(path string, handler http.Handler)

Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe will listen and serve incoming HTTP connections until the context is closed.

func (*Server) RegisterCommonHandlers added in v0.3.0

func (s *Server) RegisterCommonHandlers(
	cfg *configv1alpha1.HTTPSpec,
	registry prometheus.Gatherer,
	healthHandler HealthHandler,
	debugHandler DebugHandler,
)

RegisterCommonHandlers registers common handlers from the given HTTPSpec.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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