MCPcopy Index your code
hub / github.com/dunglas/httpsfv / valToBareItem

Function valToBareItem

httpwg_test.go:31–66  ·  view source on GitHub ↗
(e interface{})

Source from the content-addressed store, hash-verified

29}
30
31func valToBareItem(e interface{}) interface{} {
32 bareItem, ok := e.(map[string]interface{})
33 if !ok {
34 if number, ok := e.(json.Number); ok {
35 if strings.Contains(number.String(), ".") {
36 bi, _ := number.Float64()
37
38 return bi
39 }
40
41 bi, _ := number.Int64()
42
43 return bi
44 }
45
46 return e
47 }
48
49 switch bareItem["__type"] {
50 case "binary":
51 bi, _ := base32.StdEncoding.DecodeString(bareItem["value"].(string))
52
53 return bi
54 case "token":
55 return Token(bareItem["value"].(string))
56 case "date":
57 u, _ := bareItem["value"].(json.Number).Int64()
58
59 return time.Unix(u, 0)
60 case "displaystring":
61 return DisplayString(bareItem["value"].(string))
62 default:
63 }
64
65 panic("unknown type " + bareItem["__type"].(string))
66}
67
68func populateParams(p *Params, e interface{}) {
69 ex := e.([]interface{})

Callers 2

populateParamsFunction · 0.85
valToItemFunction · 0.85

Calls 2

TokenTypeAlias · 0.85
DisplayStringTypeAlias · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…