Documentation ¶
Overview ¶
Package http implements helpers for HTTP requests.
Index ¶
- Variables
- func NewHealthHandler(v ...Health) http.HandlerFuncdeprecated
- func OK(rw http.ResponseWriter, _ *http.Request)deprecated
- func OKHandler() http.Handlerdeprecated
- func RealIP(r *http.Request) string
- type Healthdeprecated
- type HealthServer
- func (s *HealthServer) AddHealthzChecks(checks ...healthz.HealthChecker) error
- func (s *HealthServer) AddLivezChecks(checks ...healthz.HealthChecker) error
- func (s *HealthServer) AddReadyzChecks(checks ...healthz.HealthChecker) error
- func (s *HealthServer) Close() error
- func (s *HealthServer) Serve(errFn func(error))
- func (s *HealthServer) Shutdown(timeout time.Duration) error
- type HealthServerConfig
- type Server
- type SrvOptFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultHealthPath = "/health"
DefaultHealthPath is the default HTTP path for checking health.
Deprecated: Use healthz instead.
Functions ¶
func NewHealthHandler
deprecated
func NewHealthHandler(v ...Health) http.HandlerFunc
NewHealthHandler returns a handler for application health checking.
Deprecated: Use healthz instead.
func OK
deprecated
added in
v2.3.0
func OK(rw http.ResponseWriter, _ *http.Request)
OK replies to the request with an HTTP 200 ok reply.
Deprecated: Use healthz instead.
Types ¶
type HealthServer ¶ added in v2.8.0
type HealthServer struct {
// contains filtered or unexported fields
}
HealthServer is an HTTP server with healthz capabilities.
func NewHealthServer
deprecated
added in
v2.8.0
func NewHealthServer(ctx context.Context, cfg HealthServerConfig, opts ...SrvOptFunc) *HealthServer
NewHealthServer returns an HTTP server with healthz capabilities.
Deprecated: Use `server.GenericServer` instead.
func (*HealthServer) AddHealthzChecks ¶ added in v2.8.0
func (s *HealthServer) AddHealthzChecks(checks ...healthz.HealthChecker) error
AddHealthzChecks adds health checks to both readyz and livez.
func (*HealthServer) AddLivezChecks ¶ added in v2.8.0
func (s *HealthServer) AddLivezChecks(checks ...healthz.HealthChecker) error
AddLivezChecks adds health checks to livez.
func (*HealthServer) AddReadyzChecks ¶ added in v2.8.0
func (s *HealthServer) AddReadyzChecks(checks ...healthz.HealthChecker) error
AddReadyzChecks adds health checks to readyz.
func (*HealthServer) Close ¶ added in v2.8.0
func (s *HealthServer) Close() error
Close closes the server.
func (*HealthServer) Serve ¶ added in v2.8.0
func (s *HealthServer) Serve(errFn func(error))
Serve installs the health checks and starts the server in a non-blocking way.
type HealthServerConfig ¶ added in v2.8.0
type HealthServerConfig struct { Addr string Handler http.Handler ReadyzChecks []healthz.HealthChecker LivezChecks []healthz.HealthChecker Stats *statter.Statter Log *logger.Logger }
HealthServerConfig configures a HealthServer.
func (*HealthServerConfig) AddHealthzChecks ¶ added in v2.9.0
func (c *HealthServerConfig) AddHealthzChecks(checks ...healthz.HealthChecker)
AddHealthzChecks adds the given checks to the config.
func (*HealthServerConfig) AddLivezChecks ¶ added in v2.9.0
func (c *HealthServerConfig) AddLivezChecks(checks ...healthz.HealthChecker)
AddLivezChecks adds the given checks to the config.
func (*HealthServerConfig) AddReadyzChecks ¶ added in v2.9.0
func (c *HealthServerConfig) AddReadyzChecks(checks ...healthz.HealthChecker)
AddReadyzChecks adds the given checks to the config.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a convenience wrapper around the standard library HTTP server.
type SrvOptFunc ¶
SrvOptFunc represents a server option function.
func WithH2C ¶ added in v2.2.0
func WithH2C() SrvOptFunc
WithH2C allows the server to handle h2c connections.
func WithReadTimeout ¶ added in v2.2.2
func WithReadTimeout(d time.Duration) SrvOptFunc
WithReadTimeout sets the server read timeout.
func WithTLSConfig ¶
func WithTLSConfig(cfg *tls.Config) SrvOptFunc
WithTLSConfig sets the serve tls config.
func WithWriteTimeout ¶ added in v2.2.2
func WithWriteTimeout(d time.Duration) SrvOptFunc
WithWriteTimeout sets the server write timeout.
Directories ¶
Path | Synopsis |
---|---|
Package healthz provides HTTP healthz handling.
|
Package healthz provides HTTP healthz handling. |
Package middleware provides reusable HTTP middleware.
|
Package middleware provides reusable HTTP middleware. |
Package render provides HTTP output rendering helper functions.
|
Package render provides HTTP output rendering helper functions. |
Package request provides functions add and extract information from an http request.
|
Package request provides functions add and extract information from an http request. |
Package server provides a generic HTTP server.
|
Package server provides a generic HTTP server. |