You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/vendor/github.com/qiniu/go-sdk/v7/reqid/reqid.go

21 lines
462 B

package reqid
import (
"context"
)
type reqidKey struct{}
// WithReqid 把reqid加入context中
func WithReqid(ctx context.Context, reqid string) context.Context {
return context.WithValue(ctx, reqidKey{}, reqid)
}
// ReqidFromContext 从context中获取reqid
func ReqidFromContext(ctx context.Context) (reqid string, ok bool) {
reqid, ok = ctx.Value(reqidKey{}).(string)
return
}
// --------------------------------------------------------------------