title: Errors when passing metadata into context in golang
body: <p>I am working on specific with <strong>handling GRPC requests</strong>. I am trying to pass the meta from my GRPC request into the context based on this code sample: <a href="https://github.com/go-kit/kit/blob/master/auth/jwt/transport.go#L47" rel="nofollow noreferrer">https://github.com/go-kit/kit/blob/master/auth/jwt/transport.go#L47</a>. </p>
  
  <p>(just in case, the contextKey explanation can be referred here: <a href="https://medium.com/@matryer/context-keys-in-go-5312346a868d#.vn10llkse" rel="nofollow noreferrer">https://medium.com/@matryer/context-keys-in-go-5312346a868d#.vn10llkse</a>):</p>
  
  <p>Below is my code:</p>
  
  <pre><code>type contextKey string
  
  func (c contextKey) String() string {
      return string(c)
  }
  
  var Headers := metadata.New(map[string]string{"auth":"", "abc": "", "xyz" : ""})
  
  func ToGRPCContext() grpctransport.RequestFunc {
      return func(ctx context.Context, md *metadata.MD) context.Context {
         for _, header := range Headers {
             val, ok := (*md)[header]
             if !ok {
                 return ctx
             }
             if len(val) &gt; 0 {
                ctx = context.WithValue(ctx, contextKey(header), val)
             }
         }
         return ctx
      }
  
  }
  </code></pre>
  
  <p>I am trying to read metadata fields (Headers) and pass it to the context. </p>
  
  <p>I am getting the following errors. <code>cannot use header (type []string) as type string in map index</code> and <code>cannot convert header (type []string) to type contextKey</code>. I had fixed the above errors by accessing the index and doing something like this <code>val, ok := (*md)[header[0]]</code>. However, I want to pass all the elements of the map to the context. </p>
  
  <p>Any suggestions on how to work around this problem?</p>