config.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. package headerwriter
  2. import (
  3. "github.com/imgproxy/imgproxy/v3/config"
  4. )
  5. // Config is the package-local configuration
  6. type Config struct {
  7. SetCanonicalHeader bool // Indicates whether to set the canonical header
  8. DefaultTTL int // Default Cache-Control max-age= value for cached images
  9. FallbackImageTTL int // TTL for images served as fallbacks
  10. CacheControlPassthrough bool // Passthrough the Cache-Control from the original response
  11. LastModifiedEnabled bool // Set the Last-Modified header
  12. EnableClientHints bool // Enable Vary header
  13. SetVaryAccept bool // Whether to include Accept in Vary header
  14. }
  15. // NewConfigFromEnv creates a new Config instance from the current configuration
  16. func NewConfigFromEnv() *Config {
  17. return &Config{
  18. SetCanonicalHeader: config.SetCanonicalHeader,
  19. DefaultTTL: config.TTL,
  20. FallbackImageTTL: config.FallbackImageTTL,
  21. LastModifiedEnabled: config.LastModifiedEnabled,
  22. CacheControlPassthrough: config.CacheControlPassthrough,
  23. EnableClientHints: config.EnableClientHints,
  24. SetVaryAccept: config.AutoWebp ||
  25. config.EnforceWebp ||
  26. config.AutoAvif ||
  27. config.EnforceAvif ||
  28. config.AutoJxl ||
  29. config.EnforceJxl,
  30. }
  31. }