2019-05-31 01:52:10 +03:00
|
|
|
package ctx
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
|
2020-01-30 14:39:00 +03:00
|
|
|
"github.com/micro/go-micro/v2/metadata"
|
2019-05-31 01:52:10 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func FromRequest(r *http.Request) context.Context {
|
|
|
|
ctx := context.Background()
|
|
|
|
md := make(metadata.Metadata)
|
|
|
|
for k, v := range r.Header {
|
|
|
|
md[k] = strings.Join(v, ",")
|
|
|
|
}
|
|
|
|
return metadata.NewContext(ctx, md)
|
|
|
|
}
|