Hello everyone, I'm creating a rate limiter, and for one route that sends a form to a Telegram bot, I want to set a different limit. The rate limit for this route is 2 requests per hour, while for regular routes, it's 2 requests per second. The line that bothers me is ip = "tg_client" + ip, and I'm not sure if it's okay to do it this way. If it's not too much trouble, please take a look at my code and let me know what do you think and how can I fix it if there is errors. Here is the code https://pastebin.com/YHNkUgF5. Thank you.
#Help with rate limiting middleware
5 messages · Page 1 of 1 (latest)
Hi!
The first thing that I spot is that you're using sleep to implement rate limiting.
I highly recommend that you at least start out with using something that has been designed for rate limiting: https://pkg.go.dev/golang.org/x/time/rate