NewDetector creates a new Detector instance
(config *Config)
| 19 | |
| 20 | // NewDetector creates a new Detector instance |
| 21 | func NewDetector(config *Config) *Detector { |
| 22 | vary := make([]string, 0, 5) |
| 23 | |
| 24 | if config.AutoWebp || config.EnforceWebp || |
| 25 | config.AutoAvif || config.EnforceAvif || |
| 26 | config.AutoJxl || config.EnforceJxl { |
| 27 | vary = append(vary, httpheaders.Accept) |
| 28 | } |
| 29 | |
| 30 | if config.EnableClientHints { |
| 31 | vary = append( |
| 32 | vary, |
| 33 | httpheaders.SecChDpr, httpheaders.Dpr, httpheaders.SecChWidth, httpheaders.Width, |
| 34 | ) |
| 35 | } |
| 36 | |
| 37 | return &Detector{ |
| 38 | config: config, |
| 39 | vary: strings.Join(vary, ", "), |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // Features detects client features from HTTP headers |
| 44 | func (d *Detector) Features(header http.Header) Features { |
no outgoing calls