Documentation
¶
Overview ¶
Package detector parses User-Agent strings and browser Client Hints.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientHints ¶
ClientHints contains the high-entropy browser hints useful for UA-reduced Chromium requests. Values are the decoded header values, without quotes.
func ClientHintsFromHeader ¶
func ClientHintsFromHeader(h http.Header) ClientHints
ClientHintsFromHeader extracts the request hints needed by Parse.
type ClientInfo ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector is safe for concurrent use after construction.
func New ¶
func New() *Detector
New creates a parser with common browser, OS, device and bot rules. It is a deliberately small baseline; production parity is obtained by loading a maintained Matomo-compatible rule set on top of this API.
func (*Detector) LoadEmbeddedMatomoRules ¶
func (d *Detector) LoadEmbeddedMatomoRules() (RuleReport, error)
LoadEmbeddedMatomoRules loads the rule corpus bundled in this Go module. Call it once during application startup; no runtime rule files are needed.
func (*Detector) LoadMatomoRules ¶
func (d *Detector) LoadMatomoRules(regexesDir string) (RuleReport, error)
LoadMatomoRules loads a checkout's regexes directory into d. The expected layout is the upstream `regexes` directory (not the repository root). Existing built-in fallback rules remain available for any unmatched UA.
func (*Detector) Middleware ¶
Middleware parses the request once and adds its Result to the request context.
type DeviceInfo ¶
type Result ¶
type Result struct {
Bot *BotInfo `json:"bot,omitempty"`
Client ClientInfo `json:"client"`
OS OSInfo `json:"os"`
Device DeviceInfo `json:"device"`
}
Result is the normalized result of parsing a request's user agent.
type RuleReport ¶
type RuleReport struct {
Loaded int
Skipped int
PCREFallback []UnsupportedRule
}
RuleReport describes a Matomo rule import.
type UnsupportedRule ¶
UnsupportedRule identifies an upstream expression that Go's RE2 engine cannot compile. The pattern is retained verbatim for migration work.