Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
func injectHeadersIntoMetadata(ctx context.Context, req *http.Request) metadata.MD {
headers := []string{
var pairs []string
for _, h := range headers {
if v := req.Header.Get(h); len(v) > 0 {
pairs = append(pairs, h, v)
return metadata.Pairs(pairs...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment