github.com/lunarobliq/gophish@v0.8.1-0.20230523153303-93511002234d/middleware/ratelimit/doc.go (about) 1 // Package ratelimit provides a simple token-bucket rate limiting middleware 2 // which only allows n POST requests every minute. This is meant to be used on 3 // login handlers or other sensitive transactions which should be throttled to 4 // prevent abuse. 5 // 6 // Tracked clients are stored in a locked map, with a goroutine that runs at a 7 // configurable interval to clean up stale entries. 8 // 9 // Note that there is no enforcement for GET requests. This is an effort to be 10 // opinionated in order to hit the most common use-cases. For more advanced 11 // use-cases, you may consider the `github.com/didip/tollbooth` package. 12 // 13 // The enforcement mechanism is based on the blog post here: 14 // https://www.alexedwards.net/blog/how-to-rate-limit-http-requests 15 package ratelimit