refactor: extract models/routes and env-based server config
- Move API request/response structs into new lib/models package - Centralize Gin route registration in lib/routing to simplify wiring - Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override - Improves modularity and makes polling behavior configurable per environmentrefactor: extract models/routes and env-based server config - Move API request/response structs into new lib/models package - Centralize Gin route registration in lib/routing to simplify wiring - Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override - Improves modularity and makes polling behavior configurable per environment
This commit is contained in:
20
lib/server/config.go
Normal file
20
lib/server/config.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func boxPollingIntervalMS() int {
|
||||
rawValue := os.Getenv("WARPBOX_BOX_POLL_INTERVAL_MS")
|
||||
if rawValue == "" {
|
||||
return boxPollInterval
|
||||
}
|
||||
|
||||
interval, err := strconv.Atoi(rawValue)
|
||||
if err != nil || interval < 1000 {
|
||||
return boxPollInterval
|
||||
}
|
||||
|
||||
return interval
|
||||
}
|
||||
Reference in New Issue
Block a user