Documentation ¶
Index ¶
- Constants
- func Device(r *http.Request) string
- func Handler(h DeviceHandler, rules *rules) http.Handler
- func HandlerMux(s *http.ServeMux, rules *rules) http.Handler
- func NewRules() *rules
- type DeviceHandler
- type MobileDetect
- func (md *MobileDetect) CheckHTTPHeadersForMobile() bool
- func (md *MobileDetect) Is(key interface{}) bool
- func (md *MobileDetect) IsKey(key int) bool
- func (md *MobileDetect) IsMobile() bool
- func (md *MobileDetect) IsTablet() bool
- func (md *MobileDetect) MobileGrade() string
- func (md *MobileDetect) PreCompileRegexRules() *MobileDetect
- func (md *MobileDetect) SetHTTPHeaders(httpHeaders map[string]string) *MobileDetect
- func (md *MobileDetect) SetUserAgent(userAgent string) *MobileDetect
- func (md *MobileDetect) Version(propertyName interface{}) string
- func (md *MobileDetect) VersionFloat(propertyName interface{}) float64
- func (md *MobileDetect) VersionFloatKey(propertyVal int) float64
- func (md *MobileDetect) VersionKey(propertyVal int) string
Constants ¶
const ( // MobileGradeA . MobileGradeA = "A" // MobileGradeB . MobileGradeB = "B" // MobileGradeC . MobileGradeC = "C" )
const ( PropMobile = iota PropBuild PropVersion PropVendorid PropIpad PropIphone PropIpod PropKindle PropChrome PropCoast PropDolfin PropFirefox PropFennec PropIe PropNetfront PropNokiabrowser PropOpera PropOperaMini PropOperaMobi PropUcBrowser PropMqqbrowser PropMicromessenger PropBaiduboxapp PropBaidubrowser PropSafari PropSkyfire PropTizen PropWebkit PropGecko PropTrident PropPresto PropIos PropAndroid PropBlackberry PropBrew PropJava PropWindowsPhoneOs PropWindowsPhone PropWindowsCe PropWindowsNt PropSymbian PropWebos )
const ( IPHONE = iota BLACKBERRY PIXEL HTC NEXUS DELL MOTOROLA SAMSUNG LG SONY ASUS XIAOMI NOKIA MICROMAX PALM VERTU PANTECH FLY WIKO IMOBILE SIMVALLEY WOLFGANG ALCATEL NINTENDO AMOI INQ ONEPLUS GENERICPHONE IPAD = iota NEXUSTABLET GOOGLETABLET SAMSUNGTABLET KINDLE SURFACETABLET HPTABLET ASUSTABLET BLACKBERRYTABLET HTCTABLET MOTOROLATABLET NOOKTABLET ACERTABLET TOSHIBATABLET LGTABLET FUJITSUTABLET PRESTIGIOTABLET LENOVOTABLET DELLTABLET YARVIKTABLET MEDIONTABLET ARNOVATABLET INTENSOTABLET IRUTABLET MEGAFONTABLET EBODATABLET ALLVIEWTABLET ARCHOSTABLET AINOLTABLET NOKIALUMIATABLET SONYTABLET PHILIPSTABLET CUBETABLET COBYTABLET MIDTABLET MSITABLET SMITTABLET ROCKCHIPTABLET FLYTABLET BQTABLET HUAWEITABLET NECTABLET PANTECHTABLET BRONCHOTABLET VERSUSTABLET ZYNCTABLET POSITIVOTABLET NABITABLET KOBOTABLET DANEWTABLET TEXETTABLET PLAYSTATIONTABLET TREKSTORTABLET PYLEAUDIOTABLET ADVANTABLET DANYTECHTABLET GALAPADTABLET MICROMAXTABLET KARBONNTABLET ALLFINETABLET PROSCANTABLET YONESTABLET CHANGJIATABLET GUTABLET POINTOFVIEWTABLET OVERMAXTABLET HCLTABLET DPSTABLET VISTURETABLET CRESTATABLET MEDIATEKTABLET CONCORDETABLET GOCLEVERTABLET MODECOMTABLET VONINOTABLET ECSTABLET STOREXTABLET VODAFONETABLET ESSENTIELBTABLET ROSSMOORTABLET IMOBILETABLET TOLINOTABLET AUDIOSONICTABLET AMPETABLET SKKTABLET TECNOTABLET JXDTABLET IJOYTABLET FX2TABLET XOROTABLET VIEWSONICTABLET VERIZONTABLET ODYSTABLET CAPTIVATABLET ICONBITTABLET TECLASTTABLET ONDATABLET JAYTECHTABLET BLAUPUNKTTABLET DIGMATABLET EVOLIOTABLET LAVATABLET AOCTABLET MPMANTABLET CELKONTABLET WOLDERTABLET MEDIACOMTABLET MITABLET NIBIRUTABLET NEXOTABLET LEADERTABLET UBISLATETABLET POCKETBOOKTABLET KOCASOTABLET HISENSETABLET HUDL TELSTRATABLET GENERICTABLET ANDROIDOS = iota BLACKBERRYOS PALMOS SYMBIANOS WINDOWSMOBILEOS WINDOWSPHONEOS IOS IPADOS SAILFISHOS MEEGOOS MAEMOOS JAVAOS WEBOS BADAOS BREWOS CHROME = iota DOLFIN OPERA SKYFIRE EDGE IE FIREFOX BOLT TEASHARK BLAZER SAFARI TIZEN WECHAT UCBROWSER BAIDUBOXAPP BAIDUBROWSER DIIGOBROWSER PUFFIN MERCURY OBIGOBROWSER NETFRONT GENERICBROWSER PALEMOON BOT = iota MOBILEBOT DESKTOPMODE TV WEBKIT CONSOLE WATCH )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeviceHandler ¶
type DeviceHandler interface { Mobile(w http.ResponseWriter, r *http.Request, m *MobileDetect) Tablet(w http.ResponseWriter, r *http.Request, m *MobileDetect) Desktop(w http.ResponseWriter, r *http.Request, m *MobileDetect) }
DeviceHandler .
type MobileDetect ¶
type MobileDetect struct {
// contains filtered or unexported fields
}
MobileDetect holds the structure to figure out a browser from a UserAgent string and methods necessary to make it happen
func New ¶
func New(r *http.Request, rules *rules) *MobileDetect
New creates the MobileDetect object
func (*MobileDetect) CheckHTTPHeadersForMobile ¶
func (md *MobileDetect) CheckHTTPHeadersForMobile() bool
CheckHTTPHeadersForMobile looks for mobile rules to confirm if the browser is a mobile browser
func (*MobileDetect) Is ¶
func (md *MobileDetect) Is(key interface{}) bool
Is It is recommended to use IsKey instead
func (*MobileDetect) IsKey ¶
func (md *MobileDetect) IsKey(key int) bool
IsKey Is compared the detected browser with a "rule" from the existing rules list
func (*MobileDetect) IsMobile ¶
func (md *MobileDetect) IsMobile() bool
IsMobile is a specific case to detect only mobile browsers.
func (*MobileDetect) IsTablet ¶
func (md *MobileDetect) IsTablet() bool
IsTablet is a specific case of detect only tablet browsers on tablets. Do not overlap with IsTablet
func (*MobileDetect) MobileGrade ¶
func (md *MobileDetect) MobileGrade() string
MobileGrade returns a graduation similar to jQuery's Graded Browse Support
func (*MobileDetect) PreCompileRegexRules ¶
func (md *MobileDetect) PreCompileRegexRules() *MobileDetect
PreCompileRegexRules .
func (*MobileDetect) SetHTTPHeaders ¶
func (md *MobileDetect) SetHTTPHeaders(httpHeaders map[string]string) *MobileDetect
SetHTTPHeaders .
func (*MobileDetect) SetUserAgent ¶
func (md *MobileDetect) SetUserAgent(userAgent string) *MobileDetect
SetUserAgent .
func (*MobileDetect) Version ¶
func (md *MobileDetect) Version(propertyName interface{}) string
Version It is recommended to use VersionKey instead
func (*MobileDetect) VersionFloat ¶
func (md *MobileDetect) VersionFloat(propertyName interface{}) float64
VersionFloat It is recommended to use VersionFloatKey instead
func (*MobileDetect) VersionFloatKey ¶
func (md *MobileDetect) VersionFloatKey(propertyVal int) float64
VersionFloatKey VersionFloat does the same as Version, but returns a float number good for version comparison
func (*MobileDetect) VersionKey ¶
func (md *MobileDetect) VersionKey(propertyVal int) string
VersionKey Version detects the browser version returning as string