Documentation
¶
Index ¶
- Constants
- func ConfigureRateLimiter(r chi.Router, cfg RateLimitConfig)
- func ConfigureRateLimiterFromConfig(r chi.Router, cfg *config.RateLimitConfig, scope RateLimitScope, ...)
- func HealthzHandler() http.Handler
- func OapiErrorHandler(w http.ResponseWriter, message string, statusCode int)
- func ReadyzHandler(timeout time.Duration, checks ...HealthChecker) http.Handler
- type HealthChecker
- type RateLimitConfig
- type RateLimitDefaults
- type RateLimitOption
- type RateLimitScope
- type RateLimitScopeDefaults
- type Server
Constants ¶
const GracefulShutdownTimeout = 5 * time.Second
GracefulShutdownTimeout is the duration to wait for graceful shutdown
Variables ¶
This section is empty.
Functions ¶
func ConfigureRateLimiter ¶ added in v1.1.0
func ConfigureRateLimiter(r chi.Router, cfg RateLimitConfig)
ConfigureRateLimiter adds rate limiting to a router with the given config
func ConfigureRateLimiterFromConfig ¶ added in v1.1.0
func ConfigureRateLimiterFromConfig( r chi.Router, cfg *config.RateLimitConfig, scope RateLimitScope, options ...RateLimitOption, )
ConfigureRateLimiterFromConfig applies rate limiting based on service config. If trustedProxies is unset, it falls back to cfg.TrustedProxies.
func HealthzHandler ¶ added in v0.10.0
HealthzHandler returns a simple HTTP handler that always returns OK. This is for liveness probes that just need to know if the process is running. The response body is empty.
func OapiErrorHandler ¶ added in v1.1.0
func OapiErrorHandler(w http.ResponseWriter, message string, statusCode int)
OapiErrorHandler is a shared error handler for OpenAPI validation errors
func ReadyzHandler ¶ added in v0.10.0
func ReadyzHandler(timeout time.Duration, checks ...HealthChecker) http.Handler
ReadyzHandler returns a simple HTTP handler that runs health checks. It iterates through provided checks and returns 503 on any failure. The response body is empty.
Types ¶
type HealthChecker ¶ added in v0.10.0
HealthChecker is a minimal contract for readiness checks.
type RateLimitConfig ¶ added in v1.1.0
type RateLimitConfig struct {
Requests int
Window time.Duration
TrustedProxies []string
Message string
}
RateLimitConfig holds rate limiting parameters
type RateLimitDefaults ¶ added in v1.1.0
type RateLimitOption ¶ added in v1.1.0
type RateLimitOption func(*rateLimitOptions)
func WithMessage ¶ added in v1.1.0
func WithMessage(message string) RateLimitOption
func WithNoTrustedProxies ¶ added in v1.1.0
func WithNoTrustedProxies() RateLimitOption
func WithRate ¶ added in v1.1.0
func WithRate(defaults RateLimitDefaults) RateLimitOption
func WithTrustedProxies ¶ added in v1.1.0
func WithTrustedProxies(trustedProxies []string) RateLimitOption
type RateLimitScope ¶ added in v1.1.0
type RateLimitScope int
const ( RateLimitScopeGeneral RateLimitScope = iota RateLimitScopeAuth )
type RateLimitScopeDefaults ¶ added in v1.1.0
type RateLimitScopeDefaults struct {
Defaults RateLimitDefaults
Message string
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}