blockyserver/internal/config/config.go
devilreef f8947fdcc4 feat: add env vars to disable render endpoints
BLOCKY_DISABLE_GLB/PNG/GIF/MP4 return 403 when set to true
2026-01-23 01:36:43 +06:00

31 lines
811 B
Go

package config
import (
"os"
"strings"
)
// EndpointConfig holds enable/disable flags for render endpoints
type EndpointConfig struct {
GLBEnabled bool
PNGEnabled bool
GIFEnabled bool
MP4Enabled bool
}
// LoadEndpointConfig reads endpoint configuration from environment variables.
// All endpoints are enabled by default.
// Set BLOCKY_DISABLE_GLB=true, BLOCKY_DISABLE_PNG=true, etc. to disable.
func LoadEndpointConfig() *EndpointConfig {
return &EndpointConfig{
GLBEnabled: !isDisabled("BLOCKY_DISABLE_GLB"),
PNGEnabled: !isDisabled("BLOCKY_DISABLE_PNG"),
GIFEnabled: !isDisabled("BLOCKY_DISABLE_GIF"),
MP4Enabled: !isDisabled("BLOCKY_DISABLE_MP4"),
}
}
func isDisabled(envVar string) bool {
val := strings.ToLower(os.Getenv(envVar))
return val == "true" || val == "1" || val == "yes"
}