我从客户端发送元数据令牌
频道频道=新频道(“127.0.0.1:50051”,ChannelCredentials.Insecure); ItemQuery item = new ItemQuery(){Id =“abc”}; var …
以下是在c#中获取元数据的代码
Metadata.Entry metadataEntry = context.RequestHeaders.FirstOrDefault(m => String.Equals(m.Key, "token", StringComparison.Ordinal)); if (metadataEntry.Equals(default(Metadata.Entry)) || metadataEntry.Value == null) { return null; } Console.WriteLine("Token value is {0}", metadataEntry.Value);
有关详细信息,请参阅 https://csharp.hotexamples.com/examples/Grpc.Core/ServerCallContext/-/php-servercallcontext-class-examples.html