feat: add env vars to disable render endpoints

BLOCKY_DISABLE_GLB/PNG/GIF/MP4 return 403 when set to true
This commit is contained in:
devilreef 2026-01-23 01:36:43 +06:00
parent ce511e1a85
commit f8947fdcc4
5 changed files with 110 additions and 7 deletions

31
internal/config/config.go Normal file
View file

@ -0,0 +1,31 @@
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"
}