fiber

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fiber provides rate limiting middleware for the Fiber v3 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

func ExtractClientIP(c fiber.Ctx, trustedProxies []string) string

ExtractClientIP securely extracts the client's real IP address from a Fiber v3 fiber.Ctx. Header values (X-Forwarded-For, X-Real-IP) are parsed only if c.IP() originates from a trusted proxy.

func New

func New(limiter *distlimit.Limiter, opts ...Option) fiber.Handler

New returns a fiber.Handler middleware for Fiber v3 configured with the specified distlimit.Limiter and options.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config holds configuration parameters for the Fiber rate limit middleware.

type Option

type Option func(*Config)

Option configures functional parameters for the Fiber rate limit middleware.

func WithKeyFunc

func WithKeyFunc(fn func(c fiber.Ctx) string) Option

WithKeyFunc configures a custom key extraction function based on fiber.Ctx.

func WithRouteLabeling added in v1.2.0

func WithRouteLabeling(enable bool) Option

WithRouteLabeling enables passing the Fiber route path pattern (e.g. /api/v1/users/:id) as the route label in telemetry events.

func WithTrustedProxies

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