Source File
autoneg.go
Belonging Package
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
package goautoneg
import (
)
type accept_slice []Accept
func ( accept_slice) () int {
:= []Accept()
return len()
}
func ( accept_slice) (, int) bool {
:= []Accept()
, := [], []
if .Q > .Q {
return true
}
if .Type != "*" && .Type == "*" {
return true
}
if .SubType != "*" && .SubType == "*" {
return true
}
return false
}
func ( accept_slice) (, int) {
:= []Accept()
[], [] = [], []
}
func ( string) ( []Accept) {
:= strings.Split(, ",")
= make([]Accept, 0, len())
for , := range {
:= strings.Trim(, " ")
:= Accept{}
.Params = make(map[string]string)
.Q = 1.0
:= strings.Split(, ";")
:= [0]
:= strings.Split(, "/")
.Type = strings.Trim([0], " ")
switch {
case len() == 1 && .Type == "*":
.SubType = "*"
case len() == 2:
.SubType = strings.Trim([1], " ")
default:
continue
}
if len() == 1 {
= append(, )
continue
}
for , := range [1:] {
:= strings.SplitN(, "=", 2)
if len() != 2 {
continue
}
:= strings.Trim([0], " ")
if == "q" {
.Q, _ = strconv.ParseFloat([1], 32)
} else {
.Params[] = strings.Trim([1], " ")
}
}
= append(, )
}
:= accept_slice()
sort.Sort()
return
}
func ( string, []string) ( string) {
:= make([][]string, 0, len())
for , := range {
= append(, strings.SplitN(, "/", 2))
}
for , := range ParseAccept() {
for , := range {
if .Type == [0] && .SubType == [1] {
= []
return
}
if .Type == [0] && .SubType == "*" {
= []
return
}
if .Type == "*" && .SubType == "*" {
= []
return
}
}
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |