Skip to content

Commit

Permalink
keep old example as BC
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaked committed Feb 12, 2015
1 parent e6f5239 commit a961ab4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"log"
"net/http"

"github.com/Shaked/gomobiledetect"
)

func handler(w http.ResponseWriter, r *http.Request) {
detect := mobiledetect.NewMobileDetect(r, nil)
requestValue := r.URL.Query().Get("r")
fmt.Fprintln(w, "isMobile?", detect.IsMobile())
fmt.Fprintln(w, "isTablet?", detect.IsTablet())
fmt.Fprintln(w, "is(request)?", requestValue, " ", detect.Is(requestValue))
fmt.Fprintln(w, "isKey(request)?", requestValue, " ", detect.IsKey(mobiledetect.IPHONE))
fmt.Fprintln(w, "Version: ", detect.Version(requestValue))
fmt.Fprintln(w, "VersionKey: ", detect.Version(mobiledetect.PROP_IPHONE))
fmt.Fprintln(w, "VersionFloat: ", detect.Version(requestValue))
fmt.Fprintln(w, "VersionFloatKey: ", detect.Version(mobiledetect.PROP_IPHONE))
}

func main() {
log.Println("Starting local server http://localhost:10001/check (cmd+click to open from terminal)")
http.HandleFunc("/check", handler)
http.ListenAndServe(":10001", nil)
}

0 comments on commit a961ab4

Please sign in to comment.