Open json7 opened 4 years ago
可以,比如:
ctx := metadata.NewContext(context.Background(), map[string]string{
"X-User-Id": "john",
"X-From-Id": "script",
})
rsp, err := cl.Hello(ctx, &pb.Request{
Name: "John",
})
也可以自己直接写入到header透传下去,但是感觉通过context更优雅. 如果没有这个机制,建议加上