MCPcopy
hub / github.com/grpc/grpc-go / FromIncomingContext

Function FromIncomingContext

metadata/metadata.go:197–211  ·  view source on GitHub ↗

FromIncomingContext returns the incoming metadata in ctx if it exists. All keys in the returned MD are lowercase.

(ctx context.Context)

Source from the content-addressed store, hash-verified

195//
196// All keys in the returned MD are lowercase.
197func FromIncomingContext(ctx context.Context) (MD, bool) {
198 md, ok := ctx.Value(mdIncomingKey{}).(MD)
199 if !ok {
200 return nil, false
201 }
202 out := make(MD, len(md))
203 for k, v := range md {
204 // We need to manually convert all keys to lower case, because MD is a
205 // map, and there's no guarantee that the MD attached to the context is
206 // created using our helper functions.
207 key := strings.ToLower(k)
208 out[key] = copyOf(v)
209 }
210 return out, true
211}
212
213// ValueFromIncomingContext returns the metadata value corresponding to the metadata
214// key from the incoming metadata if it exists. Keys are matched in a case insensitive

Callers 15

processUnaryRPCMethod · 0.92
processStreamingRPCMethod · 0.92
handleStreamMethod · 0.92
TestForceCodecNameMethod · 0.92
authorityCheckerFunction · 0.92
startServerMethod · 0.92
StreamingCallMethod · 0.92
UnaryCallMethod · 0.92
FullDuplexCallMethod · 0.92

Calls 2

copyOfFunction · 0.85
ValueMethod · 0.45

Tested by 15

TestForceCodecNameMethod · 0.74
authorityCheckerFunction · 0.74
startServerMethod · 0.74
TestCustomLBMethod · 0.74
BalanceLoadMethod · 0.74
startBackendsFunction · 0.74
authorityCheckerFunction · 0.74
authHandleFunction · 0.74