From 749f1a43e58da9d9e4b0521365729e8905fcae48 Mon Sep 17 00:00:00 2001 From: Nebulizer1213 Date: Sun, 4 Sep 2022 18:05:58 -0400 Subject: [PATCH] allow options to be nil in ratelimit.RateLimiter() --- gin_rate_limit.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gin_rate_limit.go b/gin_rate_limit.go index 96f01d6..0610370 100644 --- a/gin_rate_limit.go +++ b/gin_rate_limit.go @@ -26,6 +26,9 @@ type Options struct { // RateLimiter is a function to get gin.HandlerFunc func RateLimiter(s Store, options *Options) gin.HandlerFunc { + if options == nil { + options = &Options{} + } if options.ErrorHandler == nil { options.ErrorHandler = func(c *gin.Context, info Info) { c.Header("X-Rate-Limit-Reset", fmt.Sprintf("%.2f", time.Until(info.ResetTime).Seconds()))