add all http request metadata

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-08-11 12:47:44 +03:00
parent c1e0ce26b5
commit 3e1ffcb989

View File

@ -89,6 +89,14 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
for k, v := range r.Header { for k, v := range r.Header {
md.Set(k, strings.Join(v, ", ")) md.Set(k, strings.Join(v, ", "))
} }
md.Set("RemoteAddr", r.RemoteAddr)
md.Set("Method", r.Method)
md.Set("URL", r.URL.String())
md.Set("Proto", r.Proto)
md.Set("ContentLength", fmt.Sprintf("%d", r.ContentLength))
md.Set("TransferEncoding", strings.Join(r.TransferEncoding, ","))
md.Set("Host", r.Host)
md.Set("RequestURI", r.RequestURI)
ctx = metadata.NewIncomingContext(ctx, md) ctx = metadata.NewIncomingContext(ctx, md)
defer r.Body.Close() defer r.Body.Close()