MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / UD

Function UD

base/redactor_userdata.go:55–83  ·  view source on GitHub ↗

UD returns a UserData type for any given value.

(i interface{})

Source from the content-addressed store, hash-verified

53
54// UD returns a UserData type for any given value.
55func UD(i interface{}) RedactorFunc {
56 switch v := i.(type) {
57 case string:
58 return func() Redactor {
59 return UserData(v)
60 }
61 case RedactorBuilder:
62 return func() Redactor {
63 return v.BuildRedactor(UD)
64 }
65 case fmt.Stringer:
66 return func() Redactor {
67 return UserData(v.String())
68 }
69 case []byte:
70 return func() Redactor {
71 return UserData(string(v))
72 }
73 default:
74 return func() Redactor {
75 valueOf := reflect.ValueOf(i)
76 if valueOf.Kind() == reflect.Slice {
77 return buildRedactorFuncSlice(valueOf, UD)
78 }
79 // Fall back to a slower but safe way of getting a string from any type.
80 return UserData(fmt.Sprintf("%+v", v))
81 }
82 }
83}

Callers 15

ValidForMethod · 0.92
VerifySignatureMethod · 0.92
verifyTokenMethod · 0.92
GetProviderForIssuerMethod · 0.92
initOIDCClientMethod · 0.92
DiscoverConfigMethod · 0.92
standardDiscoveryMethod · 0.92
getJWTUsernameFunction · 0.92
getJWTClaimAsSetFunction · 0.92
verifyTokenMethod · 0.92
getPrincipalMethod · 0.92

Calls 4

UserDataTypeAlias · 0.85
buildRedactorFuncSliceFunction · 0.85
BuildRedactorMethod · 0.65
StringMethod · 0.65

Tested by 9

TestSetStringFunction · 0.74
TestTimedSetRedactionFunction · 0.74
TestUDFunction · 0.56
BenchmarkUserDataRedactFunction · 0.56
BenchmarkRedactOnLogFunction · 0.56
TestRedactErrorfFunction · 0.56
BenchmarkRedactErrorfFunction · 0.56
TestRedactedLogFuncsFunction · 0.56