How to add metadata or header ?
technomaniac opened this issue · comments
Hi @awalterschulze , I read the CreateCustom
in form.go
,and still have some questions. When we setup context metadata/header in grpc context , we will not define these kind of fields explicitly.
In my way, I will prefer to add an additional field(say as context
),this field name and value is also customized, the fake code will look like this:
contextString := req.FormValue("context")
contextStringMap := make(map[string]string)
if len(contextString) > 0 {
err := encoding_json.Unmarshal([]byte(contextString), &contextStringMap)
if err != nil {
if err != io.EOF {
w.Write([]byte("<div class=\"alert alert-danger\" role=\"alert\">" + err.Error() + "</div>"))
return
}
w.Write([]byte("<div class=\"alert alert-danger\" role=\"alert\">" + err.Error() + "</div>"))
}
}
w.Write([]byte(FormClient_RPCXXXXXX))
if !someValue {
w.Write([]byte(Footer))
return
}
for metaKey, metaValue := range contextStringMap {
// do some meta match here
}
Haha , you can check the grpc-go's oauth example for the grpc context metadata.
we will use this kind of data for auth and trace and other middleware operations
Read it as input
yep, so I fork another letmegrpc to our private repo, and will do some special edition XD
aha still WIP