DeviceAtlas Go C Wrapper API - Package carrier

import "deviceatlas/carrier"
Overview
Index

Overview

Package carrier provides a way for carrier identification based on IP addresses.

Constants

ApiVersion Public API versioning.

const ApiVersion string = "1.3.0"

func Close

func Close(f *DaGo)

Config sets a DaConfig (new or the one passed via parameter) to a DaGo instance. Allows to reuse the re-set DaGo instance, only the internal data are cleared so no calls to New can be used.

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 carrier properties from HTTP headers.

func DetectHttpRequest

func DetectHttpRequest(f *DaGo, req *http.Request) (map[string]interface{}, error)

DetectHttpRequest returns a map of carrier 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 carrier properties from HTTP headers (variadic version).

func Free

func Free(f *DaGo)

Releases the DaGo resource, a call to New will create another DaGo instance.

func LoadDataFromFile

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

LoadDataFromFile loads (and/or re-loads) the data file from a given path. For the re-loads make sure the provided Close() is called beforehand.

type DaConfig

A DaConfig describes the configuration for the device API.

type DaConfig struct {
    RealIp bool // Ip address used for the detection added to the result data
}

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 carrier 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 {
    Cd *carrierData
    // contains filtered or unexported fields
}

func New

func New() *DaGo

New creates a DaGo instance.

func NewWithConfig

func NewWithConfig(config *DaConfig) *DaGo

NewWithConfig creates a DaGo instance with custom config.

func (*DaGo) Close

func (f *DaGo) Close()

Allows to reuse the reset DaGo instance Only the internal data are cleared so no calls to New can be used.

func (*DaGo) Config

func (f *DaGo) Config(c *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 carrier properties from HTTP headers.

func (*DaGo) DetectHttpRequest

func (f *DaGo) DetectHttpRequest(req *http.Request) (map[string]interface{}, error)

DetectHttpRequest returns a map of carrier 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 carrier properties from HTTP headers (variadic version).

func (*DaGo) Free

func (f *DaGo) Free()

Releases the DaGo resource, a call to New will create another DaGo instance.

func (*DaGo) LoadDataFromFile

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

Loads (and/or re-loads) the data file from a given path. For the re-loads make sure the provided Close() is called beforehand.