ch

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Announce

func Announce(w http.ResponseWriter, headers []string)

Add Accept-CH to the response header.

Note: Client hints are accessible only on secure origins (via TLS).

Example:

ch.Announce(w, []string{headers.SecChUa, headers.SecChUaBitness})

func AnnounceNoVary

func AnnounceNoVary(w http.ResponseWriter, headers []string)

Add Accept-CH to the response header. No Vary header is added.

Note: Client hints are accessible only on secure origins (via TLS).

Example:

ch.AnnounceNoVary(w, []string{headers.SecChUa, headers.SecChUaBitness})

func ParseSecChUa

func ParseSecChUa(chUa string) map[string]string

Parse the Sec-CH-UA header. Returns a map of "brand name - version".

Example:

chUa := r.Header.Get(ch.SecChUa)
brands := ch.ParseSecChUa(chUa)

Types

type MobileType

type MobileType int
const (
	Mobile MobileType = iota
	NoMobile
	Unknown
)

func ParseChUaMobile

func ParseChUaMobile(chUaMobile string) MobileType

Determine if mobile or not.

Example:

chUaMobile := r.Header.Get(ch.SecChUaMobile)
mobileType := ch.ParseChUaMobile(chUaMobile)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL