gin

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 6 Imported by: 0

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

func ExtractClientIP(c *gin.Context, trustedProxies []string) string

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.

func New

func New(limiter *distlimit.Limiter, opts ...Option) gin.HandlerFunc

New returns a gin.HandlerFunc middleware configured with the specified distlimit.Limiter and options.

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

func WithKeyFunc(fn func(c *gin.Context) string) Option

WithKeyFunc configures a custom key extraction function based on gin.Context.

func WithTrustedProxies added in v1.1.0

func WithTrustedProxies(proxies []string) Option

WithTrustedProxies configures a list of trusted proxy IPs or CIDR networks for safely parsing X-Forwarded-For headers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL