refactor: use constants for AppEnv values (#1098)

This commit is contained in:
Alessandro (Ale) Segala
2025-11-16 09:25:06 -08:00
committed by GitHub
parent 29a1d3b778
commit a54b867105
5 changed files with 24 additions and 12 deletions

View File

@@ -41,11 +41,11 @@ func initRouter(db *gorm.DB, svc *services) utils.Service {
func initRouterInternal(db *gorm.DB, svc *services) (utils.Service, error) {
// Set the appropriate Gin mode based on the environment
switch common.EnvConfig.AppEnv {
case "production":
case common.AppEnvProduction:
gin.SetMode(gin.ReleaseMode)
case "development":
case common.AppEnvDevelopment:
gin.SetMode(gin.DebugMode)
case "test":
case common.AppEnvTest:
gin.SetMode(gin.TestMode)
}
@@ -92,7 +92,7 @@ func initRouterInternal(db *gorm.DB, svc *services) (utils.Service, error) {
controller.NewVersionController(apiGroup, svc.versionService)
// Add test controller in non-production environments
if common.EnvConfig.AppEnv != "production" {
if !common.EnvConfig.AppEnv.IsProduction() {
for _, f := range registerTestControllers {
f(apiGroup, db, svc)
}