Documentation
¶
Overview ¶
Package nethttp provides rate limiting middleware for Go's standard net/http package. 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 an http.Request. 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 net/http rate limit middleware.
type Option ¶
type Option func(*Config)
Option configures functional parameters for the net/http rate limit middleware.
func WithKeyFunc ¶ added in v1.1.0
WithKeyFunc configures a custom key extraction function from the request context.
func WithRouteLabeling ¶ added in v1.2.0
WithRouteLabeling enables passing the HTTP request URL path/pattern 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.