1package backend
 2
 3import "context"
 4
 5// ContextKey is the key for the backend in the context.
 6var ContextKey = &struct{ string }{"backend"}
 7
 8// FromContext returns the backend from a context.
 9func FromContext(ctx context.Context) *Backend {
10	if b, ok := ctx.Value(ContextKey).(*Backend); ok {
11		return b
12	}
13
14	return nil
15}
16
17// 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}