Documentation
¶
Overview ¶
Package ratelimit limits how often each client can call a Tern app:
ternApp(kit.WithPlugins(ratelimit.New(ratelimit.Rate(10, time.Minute))))
Each client gets a token bucket: up to Burst requests at once, refilled at the given rate. By default only state-changing requests (POST, PUT, PATCH, DELETE), such as form actions and API writes, are limited. A client over the limit gets 429 Too Many Requests with Retry-After.
Clients are identified by their IP address from RemoteAddr. Behind a reverse proxy, use KeyFunc to read a trusted header instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Plugin)
Option configures the plugin.
func KeyFunc ¶
KeyFunc identifies the client for a request. The default is the IP in RemoteAddr. Return "" to exempt a request.
Click to show internal directories.
Click to hide internal directories.