From 002d5c9c53f04b965092f294f04ab6a8c0c05499 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 19 May 2023 23:24:53 +0300 Subject: [PATCH] add scheme to metadata Signed-off-by: Vasiliy Tolstov --- handler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index 3018979..e476226 100644 --- a/handler.go +++ b/handler.go @@ -349,11 +349,18 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { md[k] = strings.Join(v, ", ") } md["RemoteAddr"] = r.RemoteAddr + if r.TLS != nil { + md["Scheme"] = "https" + } else { + md["Scheme"] = "http" + } md["Method"] = r.Method md["URL"] = r.URL.String() md["Proto"] = r.Proto md["ContentLength"] = fmt.Sprintf("%d", r.ContentLength) - md["TransferEncoding"] = strings.Join(r.TransferEncoding, ",") + if len(r.TransferEncoding) > 0 { + md["TransferEncoding"] = strings.Join(r.TransferEncoding, ",") + } md["Host"] = r.Host md["RequestURI"] = r.RequestURI ctx = metadata.NewIncomingContext(ctx, md) -- 2.45.2