Documentation
¶
Overview ¶
Package gin provides rate limiting middleware for the Gin web framework. It features IP spoofing protection with trusted proxy CIDR filtering and custom key extraction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractClientIP ¶ added in v1.1.0
ExtractClientIP securely extracts the client's real IP address from a Gin request context. Header values (X-Forwarded-For, X-Real-IP) are parsed only if RemoteAddr originates from a trusted proxy.
Types ¶
type Config ¶ added in v1.1.0
type Config struct {
// contains filtered or unexported fields
}
Config holds configuration parameters for the Gin rate limit middleware.
type Option ¶
type Option func(*Config)
Option configures functional parameters for the Gin rate limit middleware.
func WithKeyFunc ¶ added in v1.1.0
WithKeyFunc configures a custom key extraction function based on gin.Context.
func WithRouteLabeling ¶ added in v1.2.0
WithRouteLabeling enables passing the Gin full route path pattern (e.g. /api/v1/users/:id) as the route label in telemetry events.
func WithTrustedProxies ¶ added in v1.1.0
WithTrustedProxies configures a list of trusted proxy IPs or CIDR networks for safely parsing X-Forwarded-For headers.