config.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package imagestreamer
  2. import (
  3. "github.com/imgproxy/imgproxy/v3/config"
  4. "go.withmatt.com/httpheaders"
  5. )
  6. // Config represents the configuration for the image streamer
  7. type Config struct {
  8. // CookiePassthrough indicates whether cookies should be passed through to the image response
  9. CookiePassthrough bool
  10. // PassthroughRequestHeaders specifies the request headers to include in the passthrough response
  11. PassthroughRequestHeaders []string
  12. // KeepResponseHeaders specifies the response headers to copy from the response
  13. KeepResponseHeaders []string
  14. }
  15. // NewConfigFromEnv creates a new Config instance from environment variables
  16. func NewConfigFromEnv() *Config {
  17. return &Config{
  18. CookiePassthrough: config.CookiePassthrough,
  19. PassthroughRequestHeaders: []string{
  20. httpheaders.IfNoneMatch,
  21. httpheaders.AcceptEncoding,
  22. "Range",
  23. },
  24. KeepResponseHeaders: []string{
  25. httpheaders.ContentType,
  26. httpheaders.ContentEncoding,
  27. httpheaders.ContentRange,
  28. httpheaders.AcceptRanges,
  29. httpheaders.LastModified,
  30. httpheaders.Etag,
  31. },
  32. }
  33. }