Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 1.77 KB

README.md

File metadata and controls

77 lines (54 loc) · 1.77 KB

Go Reference Go

Go Client Hints

Install

go get -u github.com/hentaiOS-Infrastructure/fasthttp-go-client-hints

Parse Client Hints

import (
 "fmt"
 "github.com/valyala/fasthttp"

 goclienthints "github.com/hentaiOS-Infrastructure/fasthttp-go-client-hints"
)

func Handler(ctx *fasthttp.RequestCtx) {
 clientHints, err := clienthint.Parse(ctx)
 if err != nil {
  return
 }

 // Sec-CH-UA field
 fmt.Println("Brand: ", clientHints.Brand.Brand)
 fmt.Println("Brand Version: ", clientHints.BrandVersion)
 fmt.Println("Brands: ", clientHints.Brands)

 // Sec-Ch-Ua-Platform filed
 fmt.Println("Platform: ", clientHints.Platform)

 // Sec-CH-UA-Platform-Version filed
 fmt.Println("Platform Version: ", clientHints.PlatformVersion)

 // Sec-Ch-Ua-Mobile filed
 fmt.Println("IsMobile: ", clientHints.IsMobile)

 // Sec-CH-UA-Arch filed
 fmt.Println("Arch: ", clientHints.Architecture)

 // Sec-CH-UA-Bitness filed
 fmt.Println("Bitness: ", clientHints.Bitness)

 // Sec-CH-UA-Model filed
 fmt.Println("Model: ", clientHints.Model)

 // Sec-Ch-Ua-Full-Version filed
 fmt.Println("Full Version: ", clientHints.FullVersion)
}

Check Support Client Hints

import (
 "github.com/valyala/fasthttp"

 clienthint "github.com/hentaiOS-Infrastructure/fasthttp-go-client-hints"
)

func Handler2(ctx *fasthttp.RequestCtx) {
 isSupport := clienthint.IsSupportClientHints(ctx)

 if isSupport {
  // ...do something
 }
}

LICENSE

MIT