limitbase

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package limitbase provides shared helpers for the rate-limit plugin family: limit-req, limit-conn, limit-count, and graphql-limit-count.

Index

Constants

This section is empty.

Variables

View Source
var DefaultVarPattern = regexp.MustCompile(`^\$\{\s*([0-9A-Za-z_]+)\s*\?\?\s*([^{}]+?)\s*\}$`)

DefaultVarPattern matches ${name ?? default} references with an inline fallback value used by limit-conn and limit-count.

View Source
var VarPattern = regexp.MustCompile(`\$\{([0-9A-Za-z_]+)\}|\$([0-9A-Za-z_]+)`)

VarPattern matches $name and ${name} variable references in key and value expressions used by limit-req and limit-conn.

Functions

func RedisInt

func RedisInt(value any) (int64, bool)

RedisInt converts a Redis wire value to int64. Accepted types are int, int64, uint64 within int64 range, and decimal strings. Every other type and an overflowing uint64 is rejected.

Types

type QuotaHeaders

type QuotaHeaders struct {
	Limit     string
	Remaining string
	Reset     string
}

QuotaHeaders names the rate-limit response headers.

func DefaultQuotaHeaders

func DefaultQuotaHeaders(limitHeader, remainingHeader, resetHeader string) QuotaHeaders

DefaultQuotaHeaders returns the default quota header names, substituting the X-RateLimit-* names for empty fields.

func RuleQuotaHeaders

func RuleQuotaHeaders(prefix string, index int) QuotaHeaders

RuleQuotaHeaders returns per-rule quota header names, numbering the rule index plus one when no header prefix is configured.

Jump to

Keyboard shortcuts

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