Documentation
¶
Index ¶
- type Base
- func (b *Base) AddHealthEndpoint(r chi.Router, path string)
- func (b *Base) AddMetricsEndpoint(r chi.Router, path string)
- func (b *Base) AddOKEndpoint(r chi.Router, path string)
- func (b *Base) AddStatusEndpoint(r chi.Router, path string)
- func (b *Base) JWTRequestEnricher(fieldName string, claim string) func(next http.Handler) http.Handler
- func (b *Base) RateLimitByIP(config *RateLimiterConfig) func(next http.Handler) http.Handler
- func (b *Base) RateLimitByToken(config *RateLimiterConfig) func(next http.Handler) http.Handler
- func (b *Base) RateLimitByUserID(config *RateLimiterConfig) func(next http.Handler) http.Handler
- func (b *Base) ReturnErrorJSON(w http.ResponseWriter, err error)
- func (b *Base) ReturnJSON(w http.ResponseWriter, data interface{})
- func (b *Base) ReturnOKJSON(w http.ResponseWriter)
- func (b *Base) ReturnText(w http.ResponseWriter, msg string)
- func (b *Base) SimpleCORSMiddleware(next http.Handler) http.Handler
- func (b *Base) StartServer(port int, router chi.Router, timeout time.Duration)
- type RateLimitOption
- type RateLimiterConfig
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
func (*Base) JWTRequestEnricher ¶
func (*Base) RateLimitByIP ¶
RateLimitByIP creates middleware that rate limits by IP address
func (*Base) RateLimitByToken ¶
RateLimitByToken creates middleware that rate limits by JWT token or API key
func (*Base) RateLimitByUserID ¶
RateLimitByUserID creates middleware that rate limits by user ID from JWT
func (*Base) ReturnErrorJSON ¶
func (b *Base) ReturnErrorJSON(w http.ResponseWriter, err error)
func (*Base) ReturnJSON ¶
func (b *Base) ReturnJSON(w http.ResponseWriter, data interface{})
func (*Base) ReturnOKJSON ¶
func (b *Base) ReturnOKJSON(w http.ResponseWriter)
func (*Base) ReturnText ¶
func (b *Base) ReturnText(w http.ResponseWriter, msg string)
func (*Base) SimpleCORSMiddleware ¶
type RateLimitOption ¶ added in v0.0.3
type RateLimitOption func(*RateLimiterConfig)
RateLimitOption is a functional option for configuring rate limiting
func WithBurst ¶ added in v0.0.3
func WithBurst(burst int) RateLimitOption
WithBurst sets the burst limit
func WithRequestsPerSecond ¶ added in v0.0.3
func WithRequestsPerSecond(rps float64) RateLimitOption
WithRequestsPerSecond sets the requests per second limit
func WithWindow ¶ added in v0.0.3
func WithWindow(window time.Duration) RateLimitOption
WithWindow sets the time window for rate limiting
type RateLimiterConfig ¶
RateLimiterConfig holds configuration for rate limiting
func DefaultRateLimiterConfig ¶
func DefaultRateLimiterConfig() *RateLimiterConfig
DefaultRateLimiterConfig provides sensible defaults
func NewRateLimiterConfig ¶ added in v0.0.3
func NewRateLimiterConfig(options ...RateLimitOption) *RateLimiterConfig
NewRateLimiterConfig creates a new rate limiter config with options
type Status ¶
type Status struct {
Service string `json:"service"`
Healthy bool `json:"healthy"`
Version string `json:"version"`
BuildInfo string `json:"buildInfo"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Architecture string `json:"architecture"`
CPUCount int `json:"cpuCount"`
GoVersion string `json:"goVersion"`
ClientAddr string `json:"clientAddr"`
ServerHost string `json:"serverHost"`
Uptime string `json:"uptime"`
}
Click to show internal directories.
Click to hide internal directories.