rate-limiting-dynamic

command
v0.53.0 Latest Latest
Warning

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

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

README

Dynamic Rate Limiting

This example demonstrates dynamic rate limiting with custom sources that can provide different limits for different principals.

Running the Example

go run github.com/dioad/net/examples/rate-limiting-dynamic

Or build and run:

cd examples/rate-limiting-dynamic
go build
./rate-limiting-dynamic

Then test the different endpoints:

# Test premium endpoint (higher limits)
for i in {1..10}; do curl http://localhost:8080/premium; done

# Test standard endpoint (lower limits)
for i in {1..10}; do curl http://localhost:8080/standard; done

What It Demonstrates

  • Implementing a custom rate limit source
  • Providing different rate limits for different principals (e.g., premium vs. standard users)
  • Using dynamic rate limiting in HTTP middleware
  • Different rate limits for different endpoints

Code

See main.go for the complete executable example.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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