Export instance context

This commit is contained in:
世界
2021-09-19 14:05:37 +08:00
parent 486f96838d
commit 390a76ff61
2 changed files with 12 additions and 1 deletions
+7
View File
@@ -25,3 +25,10 @@ func MustFromContext(ctx context.Context) *Instance {
}
return x
}
func WithContext(ctx context.Context, v *Instance) context.Context {
if FromContext(ctx) != v {
ctx = context.WithValue(ctx, xrayKey, v)
}
return ctx
}