DeviceAtlas Go API - Package device

import "deviceatlas/device"
Overview
Index

Overview

Package device provides a way to detect devices based on the HTTP headers.

Constants

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.1.4"
const (
    DQuotes string = "\"\""
)

func Config

func Config(f *DaGo, c *DaConfig) error

Config sets a DaConfig (new or the one passed via parameter) to a DaGo instance.

func Detect

func Detect(f *DaGo, headers map[string]string) (map[string]interface{}, error)

Detect returns a map of device properties from HTTP headers.

func DetectHttpRequest

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

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

func Free(f *DaGo)

Free releases the DaGo resource (compatibility layer for device api).

func LoadDataFromFile

func LoadDataFromFile(f *DaGo, path string) (int, error)

LoadDataFromFile loads (and/or re-loads) the data file from a given path.

type DaConfig

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"
}

func NewConfig

func NewConfig() *DaConfig

NewConfig returns a default configuration used by a DaGo instance.

type DaError

A DaError describes a custom error handled by the device API.

type DaError struct {
    // contains filtered or unexported fields
}

func (DaError) Error

func (a DaError) Error() string

type DaGo

A DaGo describes the main type for the API's lifetime.

type DaGo struct {
    // contains filtered or unexported fields
}

func New

func New() *DaGo

New creates a DaGo instance with default configs.

func NewWithConfig

func NewWithConfig(config *DaConfig) *DaGo

NewWithConfig creates a DaGo instance with custom config.

func (*DaGo) Config

func (f *DaGo) Config(config *DaConfig) error

Config sets a DaConfig (new or the one passed via parameter) to a DaGo instance.

func (*DaGo) Detect

func (f *DaGo) Detect(headers map[string]string) (map[string]interface{}, error)

Detect returns a map of device properties from HTTP headers.

func (*DaGo) DetectHttpRequest

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 (*DaGo) DetectV

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 (*DaGo) Free

func (f *DaGo) Free()

Free releases the DaGo resource (compatibility layer for device api).

func (*DaGo) JSONMeta

func (f *DaGo) JSONMeta() (DaJSONMeta, error)

JSONMeta returns the data file metadata (version, date of creation).

func (*DaGo) LoadDataFromFile

func (f *DaGo) LoadDataFromFile(path string) (int, error)

LoadDataFromFile loads (and/or re-loads) the data file from a given path.

type DaJSONMeta

A DaJSONMeta describes the data file metadata.

type DaJSONMeta struct {
    Dcreation        time.Time
    Case             int
    DcreationIso8601 string
    Version          string
    Copyright        string
}

func JSONMeta

func JSONMeta(f *DaGo) (DaJSONMeta, error)

JSONMeta returns the data file metadata (version, date of creation).

type Hd

type Hd struct {
    Type int64
    Id   map[int64][]int64
    NId  map[int64]bool
    K    []int64
}

type Property

type Property struct {
    Type int
    Name string
}

type TreeError

type TreeError struct {
    // contains filtered or unexported fields
}

func (TreeError) Error

func (a TreeError) Error() string