1package backend23import "context"45// ContextKey is the key for the backend in the context.6var ContextKey = &struct{ string }{"backend"}78// FromContext returns the backend from a context.9func FromContext(ctx context.Context) *Backend {10 if b, ok := ctx.Value(ContextKey).(*Backend); ok {11 return b12 }1314 return nil15}1617// WithContext returns a new context with the backend attached.18func WithContext(ctx context.Context, b *Backend) context.Context {19 return context.WithValue(ctx, ContextKey, b)20}