Documentation
¶
Index ¶
- type Bot
- type BotCache
- type BrowserList
- type Cache
- type CacheFileList
- type CachedBot
- type CachedBotProducer
- type CachedClient
- type CachedDevice
- type CachedDeviceList
- type CachedModel
- type CachedOS
- type CachedOSVersion
- type Client
- type ClientCache
- type ClientHint
- func (c *ClientHint) Brands() map[string]string
- func (c *ClientHint) BrowserName() string
- func (c *ClientHint) IsAndroidApp() bool
- func (c *ClientHint) IsIridium() bool
- func (c *ClientHint) Mobile() string
- func (c *ClientHint) Model() string
- func (c *ClientHint) OSFamily() string
- func (c *ClientHint) OSName() string
- func (c *ClientHint) OSVersion() string
- func (c *ClientHint) Platform() string
- func (c *ClientHint) PlatformVersion() string
- type Device
- type DeviceCache
- type DeviceDetector
- func (d *DeviceDetector) BotName() string
- func (d *DeviceDetector) DeviceBrand() string
- func (d *DeviceDetector) DeviceName() string
- func (d *DeviceDetector) DeviceType() string
- func (d *DeviceDetector) FullVersion() string
- func (d *DeviceDetector) IsBot() bool
- func (d *DeviceDetector) IsKnown() bool
- func (d *DeviceDetector) LocalForkIdentifier() string
- func (d *DeviceDetector) Name() string
- func (d *DeviceDetector) OSFamily() string
- func (d *DeviceDetector) OSFullVersion() string
- func (d *DeviceDetector) OSName() string
- type EmbeddedBotCache
- type EmbeddedClientCache
- type EmbeddedDeviceCache
- func (e *EmbeddedDeviceCache) Delete(list string) DeviceCache
- func (e *EmbeddedDeviceCache) Get(list string) *CachedDeviceList
- func (e *EmbeddedDeviceCache) RegexesForHbbTV() *CacheFileList
- func (e *EmbeddedDeviceCache) RegexesForOthers() *CacheFileList
- func (e *EmbeddedDeviceCache) RegexesForShellTV() *CacheFileList
- type EmbeddedHintCache
- type EmbeddedOSCache
- type Engine
- type HintCache
- type OS
- type OSCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
type BrowserList ¶
type BrowserList struct {
// contains filtered or unexported fields
}
func (*BrowserList) Last ¶
func (b *BrowserList) Last() hintBrowser
Last returns the last browser in the list.
func (*BrowserList) Reject ¶
func (b *BrowserList) Reject(reject func(browser hintBrowser) bool) *BrowserList
Reject passes each member of the given BrowserList through a function and returns a new *BrowserList with only the entries where the func returned false.
type Cache ¶
type Cache struct {
Bot BotCache
Client ClientCache
Device DeviceCache
Hint HintCache
OS OSCache
}
func NewEmbeddedCache ¶
type CacheFileList ¶
type CacheFileList struct {
// contains filtered or unexported fields
}
CacheFileList is a helper struct used to pass a list of caches to search into the cache's findRegex function.
func NewCacheFileList ¶
func NewCacheFileList(baseList ...string) *CacheFileList
NewCacheFileList creates a new *CacheFileList, given the base list as an optional parameter. If no base is provided, uses the entires cacheFilenames array as a starting point.
func (*CacheFileList) Exclude ¶
func (c *CacheFileList) Exclude(excludes ...string) *CacheFileList
Exclude returns a new *CacheFileList with the specified files removed.
func (*CacheFileList) Exclusive ¶
func (c *CacheFileList) Exclusive(filenames ...string) *CacheFileList
Exclusive returns a copy of the *CacheFileList containing only the given filenames.
func (*CacheFileList) Get ¶
func (c *CacheFileList) Get(index int) string
Get returns the filename at the given index.
func (*CacheFileList) Includes ¶
func (c *CacheFileList) Includes(filename string) bool
Includes returns true if the given filename is in the *CacheFileList.
type CachedBot ¶
type CachedBot struct {
Regex string `yaml:"regex"`
Name string `yaml:"name"`
Category string `yaml:"category"`
URL string `yaml:"url"`
Producer CachedBotProducer `yaml:"producer"`
// contains filtered or unexported fields
}
type CachedBotProducer ¶
type CachedClient ¶
type CachedDevice ¶
type CachedDevice struct {
Regex string `yaml:"regex"`
Type string `yaml:"device"`
Name string `yaml:"model"`
Models []CachedModel `yaml:"models"`
Brand string `yaml:"-"`
// contains filtered or unexported fields
}
func (*CachedDevice) FindModel ¶
func (e *CachedDevice) FindModel(userAgent string) *CachedModel
findModel attempts to locate a matching model, if any.
type CachedDeviceList ¶
type CachedDeviceList struct {
// contains filtered or unexported fields
}
A DeviceList holds a list of devices loaded from YAML files.
func NewDeviceList ¶
func NewDeviceList() *CachedDeviceList
NewDeviceList creates a new list of devices.
func (*CachedDeviceList) Append ¶
func (d *CachedDeviceList) Append(name string, entry CachedDevice) *CachedDeviceList
Append returns a copy of the *CachedDeviceList with the given entry appended to the end of the list. If the new item already appears in the list, Append returns the original list unmodified.
func (*CachedDeviceList) Delete ¶
func (d *CachedDeviceList) Delete(item string) *CachedDeviceList
Delete deletes an item from the *CachedDeviceList. If the item is not found, the original list is returned.
type CachedModel ¶
type CachedOS ¶
type CachedOS struct {
Regex string
Name string
Version string
Versions []CachedOSVersion
// contains filtered or unexported fields
}
type CachedOSVersion ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) FullVersion ¶
type ClientCache ¶
type ClientCache interface {
Find(userAgent string) *CachedClient
}
type ClientHint ¶
type ClientHint struct {
// contains filtered or unexported fields
}
func NewClientHint ¶
func NewClientHint(cache *Cache, headers http.Header) *ClientHint
func (*ClientHint) Brands ¶
func (c *ClientHint) Brands() map[string]string
func (*ClientHint) BrowserName ¶
func (c *ClientHint) BrowserName() string
func (*ClientHint) IsAndroidApp ¶
func (c *ClientHint) IsAndroidApp() bool
IsAndroidApp returns if we are an android app based on client hints.
func (*ClientHint) IsIridium ¶
func (c *ClientHint) IsIridium() bool
func (*ClientHint) Mobile ¶
func (c *ClientHint) Mobile() string
func (*ClientHint) Model ¶
func (c *ClientHint) Model() string
func (*ClientHint) OSFamily ¶
func (c *ClientHint) OSFamily() string
OSFamily returns the operating system family according to client hints.
func (*ClientHint) OSName ¶
func (c *ClientHint) OSName() string
OSName returns the operating system name according to client hints.
func (*ClientHint) OSVersion ¶
func (c *ClientHint) OSVersion() string
OSVersion returns the operating system version according to client hints.
func (*ClientHint) Platform ¶
func (c *ClientHint) Platform() string
func (*ClientHint) PlatformVersion ¶
func (c *ClientHint) PlatformVersion() string
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
type DeviceCache ¶
type DeviceCache interface {
Delete(item string) DeviceCache
Get(list string) *CachedDeviceList
RegexesForHbbTV() *CacheFileList
RegexesForShellTV() *CacheFileList
RegexesForOthers() *CacheFileList
// contains filtered or unexported methods
}
type DeviceDetector ¶
type DeviceDetector struct {
// contains filtered or unexported fields
}
func New ¶
func New(cache *Cache, userAgent string, headers ...http.Header) *DeviceDetector
New returns a newly initialised *DeviceDetector.
func (*DeviceDetector) BotName ¶
func (d *DeviceDetector) BotName() string
BotName returns the bot name or an empty string if client is not a bot.
func (*DeviceDetector) DeviceBrand ¶
func (d *DeviceDetector) DeviceBrand() string
DeviceBrand returns the detected device brand.
func (*DeviceDetector) DeviceName ¶
func (d *DeviceDetector) DeviceName() string
DeviceName returns the detected device name.
func (*DeviceDetector) DeviceType ¶
func (d *DeviceDetector) DeviceType() string
DeviceType attempts to detect the device type.
func (*DeviceDetector) FullVersion ¶
func (d *DeviceDetector) FullVersion() string
FullVersion returns the client version.
func (*DeviceDetector) IsBot ¶
func (d *DeviceDetector) IsBot() bool
IsBot returns true if a bot is detected.
func (*DeviceDetector) IsKnown ¶
func (d *DeviceDetector) IsKnown() bool
IsKnown returns true if this client is known.
func (*DeviceDetector) LocalForkIdentifier ¶
func (d *DeviceDetector) LocalForkIdentifier() string
LocalForkIdentifier returns a unique identifier to verify this is the local fork
func (*DeviceDetector) OSFamily ¶
func (d *DeviceDetector) OSFamily() string
OSFamily returns the operating system family.
func (*DeviceDetector) OSFullVersion ¶
func (d *DeviceDetector) OSFullVersion() string
OSFullVersion returns the operating system version.
func (*DeviceDetector) OSName ¶
func (d *DeviceDetector) OSName() string
OSName returns the operating system name.
type EmbeddedBotCache ¶
type EmbeddedBotCache struct {
// contains filtered or unexported fields
}
func NewEmbeddedBotCache ¶
func NewEmbeddedBotCache() (*EmbeddedBotCache, error)
func (*EmbeddedBotCache) Find ¶
func (b *EmbeddedBotCache) Find(userAgent string) *CachedBot
type EmbeddedClientCache ¶
type EmbeddedClientCache struct {
// contains filtered or unexported fields
}
func NewEmbeddedClientCache ¶
func NewEmbeddedClientCache() (*EmbeddedClientCache, error)
func (*EmbeddedClientCache) Find ¶
func (e *EmbeddedClientCache) Find(userAgent string) *CachedClient
type EmbeddedDeviceCache ¶
type EmbeddedDeviceCache struct {
// contains filtered or unexported fields
}
func NewEmbeddedDeviceCache ¶
func NewEmbeddedDeviceCache() (*EmbeddedDeviceCache, error)
NewEmbeddedDeviceCache creates a new embedded device cache, whereby the device tree is loaded from resources contained within the package/application binary.
func (*EmbeddedDeviceCache) Delete ¶
func (e *EmbeddedDeviceCache) Delete(list string) DeviceCache
func (*EmbeddedDeviceCache) Get ¶
func (e *EmbeddedDeviceCache) Get(list string) *CachedDeviceList
Get returns the devices with the associated list name.
func (*EmbeddedDeviceCache) RegexesForHbbTV ¶
func (e *EmbeddedDeviceCache) RegexesForHbbTV() *CacheFileList
func (*EmbeddedDeviceCache) RegexesForOthers ¶
func (e *EmbeddedDeviceCache) RegexesForOthers() *CacheFileList
func (*EmbeddedDeviceCache) RegexesForShellTV ¶
func (e *EmbeddedDeviceCache) RegexesForShellTV() *CacheFileList
type EmbeddedHintCache ¶
type EmbeddedHintCache struct {
// contains filtered or unexported fields
}
func NewEmbeddedHintCache ¶
func NewEmbeddedHintCache() (*EmbeddedHintCache, error)
func (*EmbeddedHintCache) Find ¶
func (e *EmbeddedHintCache) Find(id string) string
type EmbeddedOSCache ¶
type EmbeddedOSCache struct {
// contains filtered or unexported fields
}
func NewEmbeddedOSCache ¶
func NewEmbeddedOSCache() (*EmbeddedOSCache, error)
func (*EmbeddedOSCache) Find ¶
func (e *EmbeddedOSCache) Find(userAgent string) *CachedOS
type OS ¶
type OS struct {
// contains filtered or unexported fields
}
func (*OS) FullVersion ¶
FullVersion returns the full version string of the OS. Not implemented yet.