ratelimit

package module
v0.0.0-...-d83bd77 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiterMiddleware

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

RateLimiterMiddleware implements a rate limiting middleware for HTTP requests.

func New

func New(requestsPerSecond float64, burst int) *RateLimiterMiddleware

New creates a new RateLimiterMiddleware instance.

func (*RateLimiterMiddleware) Process

func (m *RateLimiterMiddleware) Process(ctx context.Context, httpClient *http.Client, req *http.Request, next middleware.NextFunc) (*http.Response, error)

Process applies rate limiting before passing the request to the next middleware.

func (*RateLimiterMiddleware) SetLogger

func (m *RateLimiterMiddleware) SetLogger(l logger.Logger)

SetLogger sets the logger for the middleware.

Jump to

Keyboard shortcuts

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