1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00

Merge pull request #227 from ctrysbita/fix_trimleft

Fix trim prefix in bm metadata parsing
This commit is contained in:
Terry.Mao 2019-07-21 15:56:30 +08:00 committed by GitHub
commit 26dc8615cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,7 @@ var _parser = map[string]func(string) interface{}{
func parseMetadataTo(req *http.Request, to metadata.MD) {
for rawKey := range req.Header {
key := strings.ReplaceAll(strings.TrimLeft(strings.ToLower(rawKey), _httpHeaderMetadata), "-", "_")
key := strings.ReplaceAll(strings.TrimPrefix(strings.ToLower(rawKey), _httpHeaderMetadata), "-", "_")
rawValue := req.Header.Get(rawKey)
var value interface{} = rawValue
parser, ok := _parser[key]