Package device provides a way to detect devices based on the HTTP headers.
config.go device.go device_web.go dynamics.go json.go propconst.go tree.go
const ( Mixed int = 0 Lower int = 1 )
const ( Boolean int = 0 Integer int = 1 String int = 2 Unknown int = 3 )
ApiVersion Public API versioning.
const ApiVersion string = "3.2"
const ( DQuotes string = "\"\"" )
func Config(f *DaGo, c *DaConfig) error
Config sets a DaConfig (new or the one passed via parameter) to a DaGo instance.
func Detect(f *DaGo, headers map[string]string) (map[string]interface{}, error)
Detect returns a map of device properties from HTTP headers.
func DetectHttpRequest(f *DaGo, req *http.Request) (map[string]interface{}, error)
DetectHttpRequest returns a map of device properties using a DaGo and http.Request instances.
func DetectV(f *DaGo, params ...string) (map[string]interface{}, error)
DetectV returns a map of device properties from a User-Agent and optional client-side (variadic version).
func Free(f *DaGo)
Free releases the DaGo resource (compatibility layer for device api).
func LoadDataFromFile(f *DaGo, path string) (int, error)
LoadDataFromFile loads (and/or re-loads) the data file from a given path.
A DaConfig describes the configuration for the device API.
type DaConfig struct { CookieName string // cookie name that the client side properties would be set to - "DAPROPS" CacheSize uint32 // optional desired cache capacity - 0 // contains filtered or unexported fields }
func NewConfig() *DaConfig
NewConfig returns a default configuration used by a DaGo instance.
A DaError describes a custom error handled by the device API.
type DaError struct {
// contains filtered or unexported fields
}
func (a DaError) Error() string
A DaGo describes the main type for the API's lifetime.
type DaGo struct {
// contains filtered or unexported fields
}
func New() *DaGo
New creates a DaGo instance with default configs.
func NewWithConfig(config *DaConfig) *DaGo
NewWithConfig creates a DaGo instance with custom config.
func (f *DaGo) Config(config *DaConfig) error
Config sets a DaConfig (new or the one passed via parameter) to a DaGo instance.
func (f *DaGo) Detect(headers map[string]string) (map[string]interface{}, error)
Detect returns a map of device properties from HTTP headers.
func (f *DaGo) DetectHttpRequest(req *http.Request) (map[string]interface{}, error)
DetectHttpRequest returns a map of device properties using a DaGo and http.Request instances.
func (f *DaGo) DetectV(params ...string) (map[string]interface{}, error)
DetectV returns a map of device properties from a User-Agent and optional client-side (variadic version).
func (f *DaGo) Free()
Free releases the DaGo resource (compatibility layer for device api).
func (f *DaGo) JSONMeta() (DaJSONMeta, error)
JSONMeta returns the data file metadata (version, date of creation).
func (f *DaGo) LoadDataFromFile(path string) (int, error)
LoadDataFromFile loads (and/or re-loads) the data file from a given path.
A DaJSONMeta describes the data file metadata.
type DaJSONMeta struct { Dcreation time.Time Case int DcreationIso8601 string Version string Copyright string }
func JSONMeta(f *DaGo) (DaJSONMeta, error)
JSONMeta returns the data file metadata (version, date of creation).
type Hd struct { Type int64 Id map[int64][]int64 NId map[int64]bool K []int64 }
type Property struct { Type int Name string }
type TreeError struct {
// contains filtered or unexported fields
}
func (a TreeError) Error() string