mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
feat: hide rate limiter under flag
This commit is contained in:
parent
fc650b2d2a
commit
828deb52a4
@ -1,4 +1,5 @@
|
|||||||
ENV=debug
|
ENV=debug
|
||||||
PORT=3000
|
PORT=3000
|
||||||
SEED_DB=true
|
SEED_DB=true
|
||||||
|
IS_RATE_LIMITER_ENABLED=true
|
||||||
POSTGRES_URL=postgres://localhost/micrach
|
POSTGRES_URL=postgres://localhost/micrach
|
@ -10,6 +10,7 @@ type AppConfig struct {
|
|||||||
Env string
|
Env string
|
||||||
Port int
|
Port int
|
||||||
SeedDb bool
|
SeedDb bool
|
||||||
|
IsRateLimiterEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type DbConfig struct {
|
type DbConfig struct {
|
||||||
@ -34,10 +35,14 @@ func getAppConfig() AppConfig {
|
|||||||
seedDbString := os.Getenv("SEED_DB")
|
seedDbString := os.Getenv("SEED_DB")
|
||||||
seedDb := seedDbString == "true"
|
seedDb := seedDbString == "true"
|
||||||
|
|
||||||
|
isRateLimiterEnabledString := os.Getenv("IS_RATE_LIMITER_ENABLED")
|
||||||
|
isRateLimiterEnabled := isRateLimiterEnabledString == "true"
|
||||||
|
|
||||||
return AppConfig{
|
return AppConfig{
|
||||||
Env: env,
|
Env: env,
|
||||||
Port: port,
|
Port: port,
|
||||||
SeedDb: seedDb,
|
SeedDb: seedDb,
|
||||||
|
IsRateLimiterEnabled: isRateLimiterEnabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
main.go
2
main.go
@ -43,7 +43,9 @@ func main() {
|
|||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
router.LoadHTMLGlob("templates/*.html")
|
router.LoadHTMLGlob("templates/*.html")
|
||||||
router.ForwardedByClientIP = true
|
router.ForwardedByClientIP = true
|
||||||
|
if Config.App.IsRateLimiterEnabled {
|
||||||
router.Use(middleware)
|
router.Use(middleware)
|
||||||
|
}
|
||||||
router.Static("/uploads", "./uploads")
|
router.Static("/uploads", "./uploads")
|
||||||
router.Static("/static", "./static")
|
router.Static("/static", "./static")
|
||||||
router.GET("/", Controllers.GetThreads)
|
router.GET("/", Controllers.GetThreads)
|
||||||
|
Loading…
Reference in New Issue
Block a user