Welcome to mirror list, hosted at ThFree Co, Russian Federation.

metadata.go « metadata « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e78ec0843923fc33068c6d4c74519924cd02558b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package metadata

import (
	"context"

	"google.golang.org/grpc/metadata"
)

// GetValue returns the first value in the metadata slice based on a key
func GetValue(ctx context.Context, key string) string {
	md, ok := metadata.FromIncomingContext(ctx)
	if ok {
		if values, ok := md[key]; ok && len(values) > 0 {
			return values[0]
		}
	}
	return ""
}