global cleanup

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2022-05-03 14:38:44 +03:00
parent 289aadb28e
commit b075230ae5
43 changed files with 18 additions and 3012 deletions

View File

@@ -1,26 +0,0 @@
package ctx // import "go.unistack.org/micro/v3/util/ctx"
import (
"context"
"net/http"
"strings"
"go.unistack.org/micro/v3/metadata"
)
// FromRequest creates context with metadata from http.Request
func FromRequest(r *http.Request) context.Context {
ctx := r.Context()
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
md = metadata.New(len(r.Header) + 2)
}
for key, val := range r.Header {
md.Set(key, strings.Join(val, ","))
}
// pass http host
md["Host"] = r.Host
// pass http method
md["Method"] = r.Method
return metadata.NewIncomingContext(ctx, md)
}