Skip to content

Commit

Permalink
allow options to be nil in ratelimit.RateLimiter()
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulizer1213 committed Sep 4, 2022
1 parent deed734 commit 749f1a4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gin_rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 749f1a4

Please sign in to comment.