gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-grpc-middleware/util/metautils/single_key.go (about) 1 // Copyright 2016 Michal Witkowski. All Rights Reserved. 2 // See LICENSE for licensing terms. 3 4 package metautils 5 6 import ( 7 "encoding/base64" 8 "strings" 9 ) 10 11 const ( 12 binHdrSuffix = "-bin" 13 ) 14 15 func encodeKeyValue(k, v string) (string, string) { 16 k = strings.ToLower(k) 17 if strings.HasSuffix(k, binHdrSuffix) { 18 val := base64.StdEncoding.EncodeToString([]byte(v)) 19 v = string(val) 20 } 21 return k, v 22 }