Skip to content

Commit

Permalink
(NOBIDS) add config-switch to enable ratelimit (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush authored Aug 2, 2024
1 parent beeabb6 commit 1ad3de8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ func main() {
}(cfg.Metrics.Address)
}

ratelimit.Init()
router.Use(ratelimit.HttpMiddleware)
if cfg.Frontend.RatelimitEnabled {
log.Infof("enabling ratelimit")
ratelimit.Init()
router.Use(ratelimit.HttpMiddleware)
}

srv := &http.Server{
Handler: router,
Expand Down
1 change: 1 addition & 0 deletions backend/pkg/commons/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ type Config struct {
DiamondMonth int `yaml:"diamondMonth" envconfig:"FRONTEND_RATELIMITS_DIAMOND_MONTH"`
} `yaml:"ratelimits"`
RatelimitUpdateInterval time.Duration `yaml:"ratelimitUpdateInterval" envconfig:"FRONTEND_RATELIMIT_UPDATE_INTERVAL"`
RatelimitEnabled bool `yaml:"ratelimitEnabled" envconfig:"FRONTEND_RATELIMIT_ENABLED"`
SessionSecret string `yaml:"sessionSecret" envconfig:"FRONTEND_SESSION_SECRET"`
SessionSameSiteNone bool `yaml:"sessionSameSiteNone" envconfig:"FRONTEND_SESSION_SAMESITE_NONE"`
SessionCookieDomain string `yaml:"sessionCookieDomain" envconfig:"FRONTEND_SESSION_COOKIE_DOMAIN"`
Expand Down

0 comments on commit 1ad3de8

Please sign in to comment.