middleware

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package middleware provides HTTP middleware for the AppTheory limited rate limiter.

Index

Constants

View Source
const (
	IdentifierKey contextKey = "rate_limit_identifier"
)

Variables

This section is empty.

Functions

func Middleware

func Middleware(opts Options) func(http.HandlerFunc) http.HandlerFunc

func WithIdentifier

func WithIdentifier(r *http.Request, identifier string) *http.Request

Types

type Options

type Options struct {
	Limiter limited.RateLimiter

	ExtractIdentifier func(r *http.Request) string
	ExtractResource   func(r *http.Request) string
	ExtractOperation  func(r *http.Request) string

	ErrorHandler func(w http.ResponseWriter, r *http.Request, decision *limited.LimitDecision)
	OnSuccess    func(r *http.Request, decision *limited.LimitDecision)
	OnRateLimit  func(r *http.Request, decision *limited.LimitDecision)

	SkipRequest func(r *http.Request) bool
}

Options configures the HTTP rate limiting middleware.

Jump to

Keyboard shortcuts

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