From bc3a0886b0ea522ff4e9db790c36e369aa8eee66 Mon Sep 17 00:00:00 2001 From: vcarroy Date: Tue, 29 Oct 2024 12:05:03 +0100 Subject: [PATCH] feat : option to disable validation for load testing purpose --- internal/api/server.go | 2 +- internal/config/config.go | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/internal/api/server.go b/internal/api/server.go index a1d38e1..0468b44 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -83,7 +83,7 @@ func (s *Server) submitHandler(w http.ResponseWriter, r *http.Request) { return } - if !verified { + if !verified && !s.config.DisableValidation { slog.Debug("Invalid solution") http.Error(w, "Invalid solution", http.StatusBadRequest) return diff --git a/internal/config/config.go b/internal/config/config.go index dfde0a8..e37a091 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,13 +1,14 @@ package config type Config struct { - BaseUrl string `env:"ALTCHA_BASE_URL" envDefault:""` - Port string `env:"ALTCHA_PORT" envDefault:"3333"` - HmacKey string `env:"ALTCHA_HMAC_KEY"` - MaxNumber int64 `env:"ALTCHA_MAX_NUMBER" envDefault:"1000000"` - Algorithm string `env:"ALTCHA_ALGORITHM" envDefault:"SHA-256"` - Salt string `env:"ALTCHA_SALT"` - Expire string `env:"ALTCHA_EXPIRE" envDefault:"600"` - CheckExpire bool `env:"ALTCHA_CHECK_EXPIRE" envDefault:"1"` - Debug bool `env:"ALTCHA_DEBUG" envDefault:"false"` + BaseUrl string `env:"ALTCHA_BASE_URL" envDefault:""` + Port string `env:"ALTCHA_PORT" envDefault:"3333"` + HmacKey string `env:"ALTCHA_HMAC_KEY"` + MaxNumber int64 `env:"ALTCHA_MAX_NUMBER" envDefault:"1000000"` + Algorithm string `env:"ALTCHA_ALGORITHM" envDefault:"SHA-256"` + Salt string `env:"ALTCHA_SALT"` + Expire string `env:"ALTCHA_EXPIRE" envDefault:"600"` + CheckExpire bool `env:"ALTCHA_CHECK_EXPIRE" envDefault:"1"` + Debug bool `env:"ALTCHA_DEBUG" envDefault:"false"` + DisableValidation bool `env:"ATLCHA_DISABLE_VALIDATION" envDefault:"false"` } \ No newline at end of file